Skip to content

Commit afebbd5

Browse files
committed
feat: enhance window identification with ApplicationManager
1. Added ApplicationManager D-Bus integration for more accurate window identification 2. Implemented pidfd-based process identification to get desktop IDs from ApplicationManager 3. Removed desktopfileID from X11Window identity to avoid circular dependencies 4. Reordered window tracking and signal emission to ensure proper initialization 5. Added syscall and D-Bus dependencies for process identification feat: 增强窗口识别功能,集成 ApplicationManager 1. 添加 ApplicationManager D-Bus 集成以实现更精确的窗口识别 2. 实现基于 pidfd 的进程识别,从 ApplicationManager 获取桌面 ID 3. 从 X11Window 身份信息中移除 desktopfileID 以避免循环依赖 4. 重新排序窗口跟踪和信号发射以确保正确初始化 5. 添加系统调用和 D-Bus 依赖以支持进程识别
1 parent 46b02a1 commit afebbd5

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

panels/dock/taskmanager/taskmanager.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <QStandardPaths>
2828

2929
#include <appletbridge.h>
30+
#include <DSGApplication>
3031

3132
#ifdef BUILD_WITH_X11
3233
#include "x11windowmonitor.h"
@@ -128,6 +129,27 @@ bool TaskManager::init()
128129
}
129130
}
130131
}
132+
if (identifies.isEmpty())
133+
return QModelIndex();
134+
135+
pid_t windowPid = identifies.last().toInt();
136+
if (windowPid <= 0)
137+
return QModelIndex();
138+
139+
auto appId = DSGApplication::getId(windowPid);
140+
if (appId.isEmpty()) {
141+
qCDebug(taskManagerLog) << "appId is empty, AM failed to identify window with pid:" << windowPid;
142+
return QModelIndex();
143+
}
144+
145+
QString desktopId = QString::fromUtf8(appId);
146+
auto matchRes = model->match(model->index(0, 0), roleNames.key(MODEL_DESKTOPID),
147+
desktopId, 1, Qt::MatchFixedString | Qt::MatchWrap);
148+
149+
if (!matchRes.isEmpty()) {
150+
qCDebug(taskManagerLog) << "matched by AM desktop ID:" << desktopId << matchRes.value(0);
151+
return matchRes.value(0);
152+
}
131153

132154
auto res = model->match(model->index(0, 0), roleNames.key(MODEL_DESKTOPID), identifies.value(0), 1, Qt::MatchEndsWith);
133155
qCDebug(taskManagerLog) << "matched" << res.value(0);

panels/dock/taskmanager/x11window.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ QStringList X11Window::identity()
4949
{
5050
if (m_identity.isEmpty()) {
5151
m_identity = X11->getWindowWMClass(m_windowID);
52-
if (auto appItem = getAppItem()) {
53-
m_identity.append(appItem->desktopfileID());
54-
} else {
55-
qCWarning(x11windowLog) << "identify not found appitem." << id();
56-
}
5752
m_identity.append(QString::number(pid()));
5853
}
5954

panels/dock/taskmanager/x11windowmonitor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ void X11WindowMonitor::onWindowMapped(xcb_window_t xcb_window)
175175

176176
uint32_t value_list[] = { XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_VISIBILITY_CHANGE};
177177
xcb_change_window_attributes(X11->getXcbConnection(), xcb_window, XCB_CW_EVENT_MASK, value_list);
178-
Q_EMIT AbstractWindowMonitor::windowAdded(static_cast<QPointer<AbstractWindow>>(window.get()));
179178
trackWindow(window.get());
180-
179+
Q_EMIT AbstractWindowMonitor::windowAdded(static_cast<QPointer<AbstractWindow>>(window.get()));
181180
}
182181

183182
void X11WindowMonitor::onWindowDestroyed(xcb_window_t xcb_window)

0 commit comments

Comments
 (0)