From 2a226a101643f53902ea972369591ef393e170d1 Mon Sep 17 00:00:00 2001 From: donghualin Date: Fri, 22 Jul 2022 05:11:00 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=9A=84UUID=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wayland下的拖动窗口实现分屏的功能需要UUID,在此处新增wayland的UUID的返回接口 Log: 增加窗口的返回的UUID信息 Influence: wayland下,拖动任务栏的图标查看是否支持分屏 Bug: https://pms.uniontech.com/bug-view-147657.html Change-Id: If97699b74707cbf3fe3395a65f72f8bd58de3894 --- src/frameworkdbus/dbusplasmawindow.h | 72 ++--------------------- src/frameworkdbus/types/windowinfomap.cpp | 9 +-- src/frameworkdbus/types/windowinfomap.h | 1 + src/modules/dock/entry.cpp | 4 +- src/modules/dock/windowinfobase.h | 1 + src/modules/dock/windowinfok.cpp | 67 +++++++++++---------- src/modules/dock/windowinfok.h | 17 +++--- src/modules/dock/windowinfox.cpp | 5 ++ src/modules/dock/windowinfox.h | 1 + 9 files changed, 66 insertions(+), 111 deletions(-) diff --git a/src/frameworkdbus/dbusplasmawindow.h b/src/frameworkdbus/dbusplasmawindow.h index d0e2057..2e9f8e2 100644 --- a/src/frameworkdbus/dbusplasmawindow.h +++ b/src/frameworkdbus/dbusplasmawindow.h @@ -48,176 +48,132 @@ public Q_SLOTS: // METHODS return asyncCallWithArgumentList(QStringLiteral("AppId"), argumentList); } - - inline QDBusPendingReply Geometry() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Geometry"), argumentList); } - - inline QDBusPendingReply Icon() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Icon"), argumentList); } - - inline QDBusPendingReply InternalId() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("InternalId"), argumentList); } - - inline QDBusPendingReply IsActive() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsActive"), argumentList); } - - inline QDBusPendingReply IsCloseable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsCloseable"), argumentList); } - - inline QDBusPendingReply IsDemandingAttention() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsDemandingAttention"), argumentList); } - - inline QDBusPendingReply IsFullscreen() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsFullscreen"), argumentList); } - - inline QDBusPendingReply IsFullscreenable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsFullscreenable"), argumentList); } - - inline QDBusPendingReply IsKeepAbove() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsKeepAbove"), argumentList); } - - inline QDBusPendingReply IsMaximizeable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsMaximizeable"), argumentList); } - - inline QDBusPendingReply IsMaximized() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsMaximized"), argumentList); } - - inline QDBusPendingReply IsMinimizeable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsMinimizeable"), argumentList); } - - inline QDBusPendingReply IsMinimized() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsMinimized"), argumentList); } - - inline QDBusPendingReply IsMovable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsMovable"), argumentList); } - - inline QDBusPendingReply IsOnAllDesktops() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsOnAllDesktops"), argumentList); } - - inline QDBusPendingReply IsResizable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsResizable"), argumentList); } - - inline QDBusPendingReply IsShadeable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsShadeable"), argumentList); } - - inline QDBusPendingReply IsShaded() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsShaded"), argumentList); } - - inline QDBusPendingReply IsValid() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsValid"), argumentList); } - - inline QDBusPendingReply IsVirtualDesktopChangeable() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("IsVirtualDesktopChangeable"), argumentList); } - - inline QDBusPendingReply Pid() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Pid"), argumentList); } - - inline QDBusPendingReply<> RequestActivate() { QList argumentList; @@ -231,7 +187,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestActivate"), argumentList); } - inline QDBusPendingReply<> RequestClose() { QList argumentList; @@ -245,7 +200,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestClose"), argumentList); } - inline QDBusPendingReply<> RequestEnterNewVirtualDesktop() { QList argumentList; @@ -259,7 +213,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestEnterNewVirtualDesktop"), argumentList); } - inline QDBusPendingReply<> RequestEnterVirtualDesktop(const QString &argin0) { QList argumentList; @@ -275,7 +228,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestEnterVirtualDesktop"), argumentList); } - inline QDBusPendingReply<> RequestLeaveVirtualDesktop(const QString &argin0) { QList argumentList; @@ -291,7 +243,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestLeaveVirtualDesktop"), argumentList); } - inline QDBusPendingReply<> RequestMove() { QList argumentList; @@ -305,7 +256,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestMove"), argumentList); } - inline QDBusPendingReply<> RequestResize() { QList argumentList; @@ -319,7 +269,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestResize"), argumentList); } - inline QDBusPendingReply<> RequestToggleKeepAbove() { QList argumentList; @@ -333,7 +282,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestToggleKeepAbove"), argumentList); } - inline QDBusPendingReply<> RequestToggleKeepBelow() { QList argumentList; @@ -347,7 +295,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestToggleKeepBelow"), argumentList); } - inline QDBusPendingReply<> RequestToggleMaximized() { QList argumentList; @@ -361,7 +308,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestToggleMaximized"), argumentList); } - inline QDBusPendingReply<> RequestToggleMinimized() { QList argumentList; @@ -375,7 +321,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestToggleMinimized"), argumentList); } - inline QDBusPendingReply<> RequestToggleShaded() { QList argumentList; @@ -389,7 +334,6 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestToggleShaded"), argumentList); } - inline QDBusPendingReply<> RequestVirtualDesktop(uint argin0) { QList argumentList; @@ -405,47 +349,41 @@ public Q_SLOTS: // METHODS CallQueued(QStringLiteral("RequestVirtualDesktop"), argumentList); } - inline QDBusPendingReply SkipSwitcher() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("SkipSwitcher"), argumentList); } - - inline QDBusPendingReply SkipTaskbar() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("SkipTaskbar"), argumentList); } - - inline QDBusPendingReply Title() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Title"), argumentList); } - - inline QDBusPendingReply VirtualDesktop() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("VirtualDesktop"), argumentList); } - - inline QDBusPendingReply WindowId() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("WindowId"), argumentList); } - - + inline QDBusPendingReply Uuid() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("uuid"), argumentList);; + } Q_SIGNALS: // SIGNALS void ActiveChanged(); diff --git a/src/frameworkdbus/types/windowinfomap.cpp b/src/frameworkdbus/types/windowinfomap.cpp index d879797..72ec3ff 100644 --- a/src/frameworkdbus/types/windowinfomap.cpp +++ b/src/frameworkdbus/types/windowinfomap.cpp @@ -18,7 +18,7 @@ void registerWindowInfoMetaType() QDebug operator<<(QDebug argument, const WindowInfo &info) { - argument << '(' << info.title << ',' << info.attention << ')'; + argument << '(' << info.title << ',' << info.attention << info.uuid << ')'; return argument; } @@ -26,7 +26,7 @@ QDebug operator<<(QDebug argument, const WindowInfo &info) QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info) { argument.beginStructure(); - argument << info.title << info.attention; + argument << info.title << info.attention << info.uuid; argument.endStructure(); return argument; @@ -35,7 +35,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const WindowInfo &info) const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info) { argument.beginStructure(); - argument >> info.title >> info.attention; + argument >> info.title >> info.attention >> info.uuid; argument.endStructure(); return argument; @@ -44,5 +44,6 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, WindowInfo &info) bool WindowInfo::operator==(const WindowInfo &rhs) const { return attention == rhs.attention && - title == rhs.title; + title == rhs.title && + uuid == rhs.uuid; } diff --git a/src/frameworkdbus/types/windowinfomap.h b/src/frameworkdbus/types/windowinfomap.h index 711c684..2e33b20 100644 --- a/src/frameworkdbus/types/windowinfomap.h +++ b/src/frameworkdbus/types/windowinfomap.h @@ -17,6 +17,7 @@ public: public: bool attention; QString title; + QString uuid; }; Q_DECLARE_METATYPE(WindowInfo) diff --git a/src/modules/dock/entry.cpp b/src/modules/dock/entry.cpp index f078150..3957ef7 100644 --- a/src/modules/dock/entry.cpp +++ b/src/modules/dock/entry.cpp @@ -422,6 +422,7 @@ void Entry::updateExportWindowInfos() XWindow xid = info->getXid(); winInfo.title = info->getTitle(); winInfo.attention = info->isDemandingAttention(); + winInfo.uuid = info->uuid(); infos[xid] = winInfo; } @@ -431,7 +432,8 @@ void Entry::updateExportWindowInfos() for (auto iter = infos.begin(); iter != infos.end(); iter++) { XWindow xid = iter.key(); if (infos[xid].title != m_exportWindowInfos[xid].title || - infos[xid].attention != m_exportWindowInfos[xid].attention) { + infos[xid].attention != m_exportWindowInfos[xid].attention || + infos[xid].uuid != m_exportWindowInfos[xid].uuid) { changed = true; break; } diff --git a/src/modules/dock/windowinfobase.h b/src/modules/dock/windowinfobase.h index 1daf7bc..db92049 100644 --- a/src/modules/dock/windowinfobase.h +++ b/src/modules/dock/windowinfobase.h @@ -55,6 +55,7 @@ public: virtual bool allowClose() = 0; virtual void update() = 0; virtual void killClient() = 0; + virtual QString uuid() = 0; XWindow getXid() {return xid;} void setEntry(Entry *value) {entry = value;} diff --git a/src/modules/dock/windowinfok.cpp b/src/modules/dock/windowinfok.cpp index bef5963..6ed466a 100644 --- a/src/modules/dock/windowinfok.cpp +++ b/src/modules/dock/windowinfok.cpp @@ -28,12 +28,12 @@ WindowInfoK::WindowInfoK(PlasmaWindow *window, XWindow _xid) : WindowInfoBase () - , updateCalled(false) - , internalId(0) - , demaningAttention(false) - , closeable(true) - , minimized(true) - , plasmaWindow(window) + , m_updateCalled(false) + , m_internalId(0) + , m_demaningAttention(false) + , m_closeable(true) + , m_minimized(true) + , m_plasmaWindow(window) { xid = _xid; createdTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); // 获取当前时间,精确到纳秒 @@ -46,23 +46,23 @@ WindowInfoK::~WindowInfoK() bool WindowInfoK::shouldSkip() { - if (!updateCalled) { + if (!m_updateCalled) { update(); - updateCalled = true; + m_updateCalled = true; } - bool skip = plasmaWindow->SkipTaskbar(); + bool skip = m_plasmaWindow->SkipTaskbar(); // 添加窗口能否最小化判断, 如果窗口不能最小化则隐藏任务栏图标 bool canMinimize = false; - canMinimize = plasmaWindow->IsMinimizeable(); + canMinimize = m_plasmaWindow->IsMinimizeable(); if (!canMinimize) skip = true; if (skip) { // 白名单, 过滤类似“欢迎应用”, 没有最小化窗口但是需要在任务栏显示图标 QStringList list { "dde-introduction"}; - if (list.indexOf(appId) != -1) + if (list.indexOf(m_appId) != -1) skip = false; } @@ -81,42 +81,42 @@ QString WindowInfoK::getTitle() bool WindowInfoK::isDemandingAttention() { - return demaningAttention; + return m_demaningAttention; } bool WindowInfoK::allowClose() { - return closeable; + return m_closeable; } void WindowInfoK::close(uint32_t timestamp) { - plasmaWindow->RequestClose(); + m_plasmaWindow->RequestClose(); } QString WindowInfoK::getAppId() { - return appId; + return m_appId; } void WindowInfoK::setAppId(QString _appId) { - appId = _appId; + m_appId = _appId; } void WindowInfoK::activate() { - plasmaWindow->RequestActivate(); + m_plasmaWindow->RequestActivate(); } void WindowInfoK::minimize() { - plasmaWindow->RequestToggleMinimized(); + m_plasmaWindow->RequestToggleMinimized(); } bool WindowInfoK::isMinimized() { - return minimized; + return m_minimized; } bool WindowInfoK::changeXid(XWindow _xid) @@ -127,52 +127,52 @@ bool WindowInfoK::changeXid(XWindow _xid) PlasmaWindow *WindowInfoK::getPlasmaWindow() { - return plasmaWindow; + return m_plasmaWindow; } bool WindowInfoK::updateGeometry() { - DockRect rect = plasmaWindow->Geometry(); - if (geometry == rect) + DockRect rect = m_plasmaWindow->Geometry(); + if (m_geometry == rect) return false; - geometry = rect; + m_geometry = rect; return true; } void WindowInfoK::updateTitle() { - title = plasmaWindow->Title(); + title = m_plasmaWindow->Title(); } void WindowInfoK::updateDemandingAttention() { - demaningAttention = plasmaWindow->IsDemandingAttention(); + m_demaningAttention = m_plasmaWindow->IsDemandingAttention(); } void WindowInfoK::updateIcon() { - icon = plasmaWindow->Icon(); + icon = m_plasmaWindow->Icon(); } void WindowInfoK::updateAppId() { - appId = plasmaWindow->AppId(); + m_appId = m_plasmaWindow->AppId(); } void WindowInfoK::updateInternalId() { - internalId = plasmaWindow->InternalId(); + m_internalId = m_plasmaWindow->InternalId(); } void WindowInfoK::updateCloseable() { - closeable = plasmaWindow->IsCloseable(); + m_closeable = m_plasmaWindow->IsCloseable(); } void WindowInfoK::updateProcessInfo() { - pid = plasmaWindow->Pid(); + pid = m_plasmaWindow->Pid(); processInfo = new ProcessInfo(pid); } @@ -182,7 +182,7 @@ void WindowInfoK::updateProcessInfo() */ DockRect WindowInfoK::getGeometry() { - return geometry; + return m_geometry; } int64_t WindowInfoK::getCreatedTime() @@ -217,3 +217,8 @@ void WindowInfoK::killClient() { } +QString WindowInfoK::uuid() +{ + return QString(m_plasmaWindow->Uuid()); +} + diff --git a/src/modules/dock/windowinfok.h b/src/modules/dock/windowinfok.h index 9f282e2..53225ab 100644 --- a/src/modules/dock/windowinfok.h +++ b/src/modules/dock/windowinfok.h @@ -51,6 +51,7 @@ public: virtual QString getWindowType() override; virtual void update() override; virtual void killClient() override; + virtual QString uuid() override; QString getAppId(); void setAppId(QString _appId); @@ -67,14 +68,14 @@ public: DockRect getGeometry(); private: - bool updateCalled; - QString appId; - uint32_t internalId; - bool demaningAttention; - bool closeable; - bool minimized; - PlasmaWindow *plasmaWindow; - DockRect geometry; + bool m_updateCalled; + QString m_appId; + uint32_t m_internalId; + bool m_demaningAttention; + bool m_closeable; + bool m_minimized; + PlasmaWindow *m_plasmaWindow; + DockRect m_geometry; }; #endif // WINDOWINFOK_H diff --git a/src/modules/dock/windowinfox.cpp b/src/modules/dock/windowinfox.cpp index 8c076fb..722437c 100644 --- a/src/modules/dock/windowinfox.cpp +++ b/src/modules/dock/windowinfox.cpp @@ -189,6 +189,11 @@ void WindowInfoX::killClient() XCB->killClientChecked(xid); } +QString WindowInfoX::uuid() +{ + return QString(); +} + QString WindowInfoX::getGtkAppId() { return gtkAppId; diff --git a/src/modules/dock/windowinfox.h b/src/modules/dock/windowinfox.h index 88b4226..387a96b 100644 --- a/src/modules/dock/windowinfox.h +++ b/src/modules/dock/windowinfox.h @@ -50,6 +50,7 @@ public: virtual bool allowClose() override; virtual void update() override; virtual void killClient() override; + virtual QString uuid() override; QString genInnerId(WindowInfoX *winInfo); QString getGtkAppId();