fix: 修复新打开应用的窗口没有attach到任务栏上对应的应用图标的问题
修复新打开应用的窗口没有attach到任务栏上对应的应用图标的问题 Log: Task: https://pms.uniontech.com/task-view-138279.html Influence: 新打开的应用可以显示在任务栏 Change-Id: I9762d84ba2ffc86dfea7b6e5c219eee8dbe85245
This commit is contained in:
parent
7cb147fb39
commit
8c0836b1cf
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@
|
|||||||
#define XCB XCBUtils::instance()
|
#define XCB XCBUtils::instance()
|
||||||
|
|
||||||
X11Manager::X11Manager(Dock *_dock, QObject *parent)
|
X11Manager::X11Manager(Dock *_dock, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, dock(_dock)
|
, dock(_dock)
|
||||||
, mutex(QMutex(QMutex::NonRecursive))
|
, mutex(QMutex(QMutex::NonRecursive))
|
||||||
, listenXEvent(true)
|
, listenXEvent(true)
|
||||||
{
|
{
|
||||||
rootWindow = XCB->getRootWindow();
|
rootWindow = XCB->getRootWindow();
|
||||||
}
|
}
|
||||||
@ -61,35 +61,35 @@ void X11Manager::listenXEventUseXlib()
|
|||||||
dpy = XOpenDisplay (displayname);
|
dpy = XOpenDisplay (displayname);
|
||||||
if (!dpy) {
|
if (!dpy) {
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
screen = DefaultScreen (dpy);
|
screen = DefaultScreen (dpy);
|
||||||
w = RootWindow(dpy, screen);
|
w = RootWindow(dpy, screen);
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
long mask;
|
long mask;
|
||||||
} events[] = {
|
} events[] = {
|
||||||
{ "keyboard", KeyPressMask | KeyReleaseMask | KeymapStateMask },
|
{ "keyboard", KeyPressMask | KeyReleaseMask | KeymapStateMask },
|
||||||
{ "mouse", ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
{ "mouse", ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
||||||
LeaveWindowMask | PointerMotionMask | Button1MotionMask |
|
LeaveWindowMask | PointerMotionMask | Button1MotionMask |
|
||||||
Button2MotionMask | Button3MotionMask | Button4MotionMask |
|
Button2MotionMask | Button3MotionMask | Button4MotionMask |
|
||||||
Button5MotionMask | ButtonMotionMask },
|
Button5MotionMask | ButtonMotionMask },
|
||||||
{ "button", ButtonPressMask | ButtonReleaseMask },
|
{ "button", ButtonPressMask | ButtonReleaseMask },
|
||||||
{ "expose", ExposureMask },
|
{ "expose", ExposureMask },
|
||||||
{ "visibility", VisibilityChangeMask },
|
{ "visibility", VisibilityChangeMask },
|
||||||
{ "structure", StructureNotifyMask },
|
{ "structure", StructureNotifyMask },
|
||||||
{ "substructure", SubstructureNotifyMask | SubstructureRedirectMask },
|
{ "substructure", SubstructureNotifyMask | SubstructureRedirectMask },
|
||||||
{ "focus", FocusChangeMask },
|
{ "focus", FocusChangeMask },
|
||||||
{ "property", PropertyChangeMask },
|
{ "property", PropertyChangeMask },
|
||||||
{ "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++)
|
||||||
mask |= events[i].mask;
|
mask |= events[i].mask;
|
||||||
|
|
||||||
attr.event_mask = mask;
|
attr.event_mask = mask;
|
||||||
|
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理需要移除的窗口
|
// 处理需要移除的窗口
|
||||||
@ -296,10 +300,10 @@ void X11Manager::handleMapNotifyEvent(XWindow xid)
|
|||||||
|
|
||||||
// TODO QTimer不能在非主线程执行,使用单独线程开发定时器处理非主线程类似定时任务
|
// TODO QTimer不能在非主线程执行,使用单独线程开发定时器处理非主线程类似定时任务
|
||||||
//QTimer::singleShot(2 * 1000, this, [=] {
|
//QTimer::singleShot(2 * 1000, this, [=] {
|
||||||
qInfo() << "handleMapNotifyEvent: pass 2s, now call idnetifyWindow, windowId=" << winInfo->getXid();
|
qInfo() << "handleMapNotifyEvent: pass 2s, now call idnetifyWindow, windowId=" << winInfo->getXid();
|
||||||
QString innerId;
|
QString innerId;
|
||||||
AppInfo *appInfo = dock->identifyWindow(winInfo, innerId);
|
AppInfo *appInfo = dock->identifyWindow(winInfo, innerId);
|
||||||
dock->markAppLaunched(appInfo);
|
dock->markAppLaunched(appInfo);
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +433,7 @@ QPair<ConfigureEvent *, QTimer *> X11Manager::getWindowLastConfigureEvent(XWindo
|
|||||||
QPair<ConfigureEvent *, QTimer *> ret;
|
QPair<ConfigureEvent *, QTimer *> ret;
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
if (windowLastConfigureEventMap.find(xid) != windowLastConfigureEventMap.end())
|
if (windowLastConfigureEventMap.find(xid) != windowLastConfigureEventMap.end())
|
||||||
ret = windowLastConfigureEventMap[xid];
|
ret = windowLastConfigureEventMap[xid];
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user