Skip to content

Commit 272150e

Browse files
committed
feat: add icon theme change handling for X11 windows
1. Added resetIcon() method to X11Window class to clear cached icon and emit change signal 2. Implemented icon theme change detection in X11WindowMonitor 3. Added connection to DGuiApplicationHelper's theme change signal 4. When theme changes, all window icons are reset to force reload with new theme 5. This ensures task manager icons update properly when system icon theme changes feat: 为X11窗口添加图标主题变更处理 1. 在X11Window类中添加resetIcon()方法用于清除缓存的图标并发出变更信号 2. 在X11WindowMonitor中实现图标主题变更检测 3. 添加与DGuiApplicationHelper主题变更信号的连接 4. 当主题变更时,所有窗口图标会被重置以强制使用新主题重新加载 5. 这确保了任务管理器图标在系统图标主题变更时能正确更新
1 parent 5e607a5 commit 272150e

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

panels/dock/taskmanager/x11window.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ QString X11Window::icon()
6363
return m_icon;
6464
}
6565

66+
void X11Window::resetIcon()
67+
{
68+
if (!m_icon.isEmpty()) {
69+
m_icon.clear();
70+
Q_EMIT AbstractWindow::iconChanged();
71+
}
72+
}
73+
6674
QString X11Window::title()
6775
{
6876
if (m_title.isEmpty()) {

panels/dock/taskmanager/x11window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class X11Window : public AbstractWindow
4141
friend class X11WindowMonitor;
4242
X11Window(xcb_window_t winid, QObject *parent = nullptr);
4343

44+
void resetIcon();
45+
4446
private:
4547
void updatePid();
4648
void updateIdentify();

panels/dock/taskmanager/x11windowmonitor.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <xcb/xproto.h>
1616

1717
#include <DDBusSender>
18+
#include <DGuiApplicationHelper>
19+
#include <DPlatformTheme>
1820

1921
#include <QPointer>
2022
#include <QWindow>
@@ -50,6 +52,7 @@ X11WindowMonitor::X11WindowMonitor(QObject* parent)
5052
connect(this, &X11WindowMonitor::windowMapped, this, &X11WindowMonitor::onWindowMapped);
5153
connect(this, &X11WindowMonitor::windowDestroyed, this, &X11WindowMonitor::onWindowDestroyed);
5254
connect(this, &X11WindowMonitor::windowPropertyChanged, this, &X11WindowMonitor::onWindowPropertyChanged);
55+
connect(DGuiApplicationHelper::instance()->applicationTheme(), &DPlatformTheme::iconThemeNameChanged, this, &X11WindowMonitor::onIconThemeChanged);
5356
}
5457

5558
void X11WindowMonitor::start()
@@ -201,6 +204,15 @@ void X11WindowMonitor::onWindowPropertyChanged(xcb_window_t window, xcb_atom_t a
201204
}
202205
}
203206

207+
void X11WindowMonitor::onIconThemeChanged()
208+
{
209+
for (const auto &window : m_windows) {
210+
if (window) {
211+
window->resetIcon();
212+
}
213+
}
214+
}
215+
204216
void X11WindowMonitor::handleRootWindowPropertyNotifyEvent(xcb_atom_t atom)
205217
{
206218
if (atom == X11->getAtomByName("_NET_CLIENT_LIST")) {

panels/dock/taskmanager/x11windowmonitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private Q_SLOTS:
5151
void onWindowMapped(xcb_window_t window);
5252
void onWindowDestroyed(xcb_window_t window);
5353
void onWindowPropertyChanged(xcb_window_t window, xcb_atom_t atom);
54+
void onIconThemeChanged();
5455

5556
private:
5657
void monitorX11Event();

0 commit comments

Comments
 (0)