fix: 修复新打开应用的窗口没有attach到任务栏上对应的应用图标的问题

修复新打开应用的窗口没有attach到任务栏上对应的应用图标的问题

Log:
Task: https://pms.uniontech.com/task-view-138279.html
Influence: 新打开的应用可以显示在任务栏
Change-Id: I9762d84ba2ffc86dfea7b6e5c219eee8dbe85245
This commit is contained in:
weizhixiang 2022-05-31 21:36:06 +08:00
parent 7cb147fb39
commit 8c0836b1cf
5 changed files with 46 additions and 40 deletions

View File

@ -83,7 +83,8 @@ Dock::Dock(QObject *parent)
}); });
thread.detach(); thread.detach();
x11Manager->listenRootWindowXEvent(); x11Manager->listenRootWindowXEvent();
connect(x11Manager, SIGNAL(X11Manager::requestUpdateHideState), this, SLOT(updateHideState)); connect(x11Manager, &X11Manager::requestUpdateHideState, this, &Dock::updateHideState);
connect(x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &Dock::attachOrDetachWindow);
} }
Q_EMIT serviceRestarted(); Q_EMIT serviceRestarted();
} }
@ -395,7 +396,7 @@ WindowInfoBase *Dock::getActiveWindow()
void Dock::doActiveWindow(XWindow xid) void Dock::doActiveWindow(XWindow xid)
{ {
XCB->changeActiveWindow(xid); XCB->changeActiveWindow(xid);
QTimer::singleShot(0, [&] { QTimer::singleShot(50, [&] {
XCB->restackWindow(xid); XCB->restackWindow(xid);
}); });
} }

View File

@ -62,7 +62,6 @@ public:
QString getWMName(); QString getWMName();
void setWMName(QString name); void setWMName(QString name);
void setPropHideState(HideState state); void setPropHideState(HideState state);
void attachOrDetachWindow(WindowInfoBase *info);
void attachWindow(WindowInfoBase *info); void attachWindow(WindowInfoBase *info);
void detachWindow(WindowInfoBase *info); void detachWindow(WindowInfoBase *info);
void launchApp(const QString desktopFile, uint32_t timestamp, QStringList files); void launchApp(const QString desktopFile, uint32_t timestamp, QStringList files);
@ -154,8 +153,9 @@ Q_SIGNALS:
void hideStateChanged(int); void hideStateChanged(int);
void frontendWindowRectChanged(); void frontendWindowRectChanged();
private Q_SLOTS: public Q_SLOTS:
void smartHideModeTimerExpired(); void smartHideModeTimerExpired();
void attachOrDetachWindow(WindowInfoBase *info);
private: private:
void initSettings(); void initSettings();

View File

@ -97,7 +97,7 @@ QString WindowInfoX::getIcon()
void WindowInfoX::activate() void WindowInfoX::activate()
{ {
XCB->changeActiveWindow(xid); XCB->changeActiveWindow(xid);
QTimer::singleShot(0, [&] { QTimer::singleShot(50, [&] {
XCB->restackWindow(xid); XCB->restackWindow(xid);
}); });
} }

View File

@ -85,7 +85,7 @@ void X11Manager::listenXEventUseXlib()
{ "colormap", ColormapChangeMask }, { "colormap", ColormapChangeMask },
{ "owner_grab_button", OwnerGrabButtonMask }, { "owner_grab_button", OwnerGrabButtonMask },
{ nullptr, 0 } { nullptr, 0 }
}; };
long mask = 0; long mask = 0;
for (int i = 0; events[i].name; i++) for (int i = 0; events[i].name; i++)
@ -221,8 +221,12 @@ void X11Manager::handleClientListChanged()
WMClass wmClass = XCB->getWMClass(xid); WMClass wmClass = XCB->getWMClass(xid);
QString wmName(XCB->getWMName(xid).c_str()); QString wmName(XCB->getWMName(xid).c_str());
if (pid != 0 || (wmClass.className.size() > 0 && wmClass.instanceName.size() > 0) if (pid != 0 || (wmClass.className.size() > 0 && wmClass.instanceName.size() > 0)
|| wmName.size() > 0 || XCB->getWMCommand(xid).size() > 0) || wmName.size() > 0 || XCB->getWMCommand(xid).size() > 0) {
dock->attachOrDetachWindow(info); WindowInfoBase *base = static_cast<WindowInfoBase *>(info);
if (base) {
Q_EMIT requestAttachOrDetachWindow(base);
}
}
} }
// 处理需要移除的窗口 // 处理需要移除的窗口

View File

@ -60,6 +60,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void requestUpdateHideState(bool delay); void requestUpdateHideState(bool delay);
void requestAttachOrDetachWindow(WindowInfoBase *info);
private: private:
void addWindowLastConfigureEvent(XWindow xid, ConfigureEvent* event); void addWindowLastConfigureEvent(XWindow xid, ConfigureEvent* event);