diff --git a/src/activities.cpp b/src/activities.cpp index 9bc6fc34ea..ab929dc5ae 100644 --- a/src/activities.cpp +++ b/src/activities.cpp @@ -8,8 +8,8 @@ */ #include "activities.h" // KWin -#include "window.h" #include "workspace.h" +#include "x11window.h" // KDE #include // Qt @@ -175,13 +175,14 @@ void Activities::reallyStop(const QString &id) QSet dontCloseSessionIds; const auto windows = ws->windows(); for (auto *const window : windows) { - if (!window->isClient()) { + auto x11Window = qobject_cast(window); + if (!window || window->isUnmanaged()) { continue; } if (window->isDesktop()) { continue; } - const QByteArray sessionId = window->sessionId(); + const QByteArray sessionId = x11Window->sessionId(); if (sessionId.isEmpty()) { continue; // TODO support old wm_command apps too? } diff --git a/src/window.cpp b/src/window.cpp index 68309fe5a3..9ad7ac18a5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -70,7 +70,6 @@ Window::Window() , m_internalId(QUuid::createUuid()) , m_client() , m_clientMachine(new ClientMachine(this)) - , m_wmClientLeader(XCB_WINDOW_NONE) , m_skipCloseAnimation(false) , m_colorScheme(QStringLiteral("kdeglobals")) , m_moveResizeOutput(workspace()->activeOutput()) @@ -174,54 +173,6 @@ QRectF Window::visibleGeometry() const return QRectF(); } -Xcb::Property Window::fetchWmClientLeader() const -{ - return Xcb::Property(false, window(), atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000); -} - -void Window::readWmClientLeader(Xcb::Property &prop) -{ - m_wmClientLeader = prop.value(window()); -} - -void Window::getWmClientLeader() -{ - auto prop = fetchWmClientLeader(); - readWmClientLeader(prop); -} - -/** - * Returns sessionId for this window, - * taken either from its window or from the leader window. - */ -QByteArray Window::sessionId() const -{ - QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id); - if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { - result = Xcb::StringProperty(m_wmClientLeader, atoms->sm_client_id); - } - return result; -} - -/** - * Returns command property for this window, - * taken either from its window or from the leader window. - */ -QString Window::wmCommand() -{ - QByteArray result = Xcb::StringProperty(window(), XCB_ATOM_WM_COMMAND); - if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { - result = Xcb::StringProperty(m_wmClientLeader, XCB_ATOM_WM_COMMAND); - } - result.replace(0, ' '); - return result; -} - -void Window::getWmClientMachine() -{ - m_clientMachine->resolve(window(), wmClientLeader()); -} - /** * Returns client machine for this window, * taken either from its window or from the leader window. @@ -239,18 +190,6 @@ QString Window::wmClientMachine(bool use_localhost) const return m_clientMachine->hostName(); } -/** - * Returns client leader window for this client. - * Returns the client window itself if no leader window is defined. - */ -xcb_window_t Window::wmClientLeader() const -{ - if (m_wmClientLeader != XCB_WINDOW_NONE) { - return m_wmClientLeader; - } - return window(); -} - void Window::setResourceClass(const QString &name, const QString &className) { resource_name = name; diff --git a/src/window.h b/src/window.h index a0ef917e61..82105f49c1 100644 --- a/src/window.h +++ b/src/window.h @@ -672,14 +672,11 @@ public: void setLockScreenOverlay(bool allowed); virtual QString windowRole() const; - QByteArray sessionId() const; QString resourceName() const; QString resourceClass() const; - QString wmCommand(); QString wmClientMachine(bool use_localhost) const; - const ClientMachine *clientMachine() const; + ClientMachine *clientMachine() const; virtual bool isLocalhost() const; - xcb_window_t wmClientLeader() const; virtual pid_t pid() const; static bool resourceMatch(const Window *c1, const Window *c2); @@ -1475,10 +1472,6 @@ Q_SIGNALS: protected: void setWindowHandles(xcb_window_t client); - Xcb::Property fetchWmClientLeader() const; - void readWmClientLeader(Xcb::Property &p); - void getWmClientLeader(); - void getWmClientMachine(); virtual std::unique_ptr createItem(Scene *scene) = 0; @@ -1801,7 +1794,6 @@ private: QString resource_name; QString resource_class; ClientMachine *m_clientMachine; - xcb_window_t m_wmClientLeader; bool m_skipCloseAnimation; QPointer m_surface; // when adding new data members, check also copyToDeleted() @@ -2143,7 +2135,7 @@ inline QString Window::resourceClass() const return resource_class; // it is always lowercase } -inline const ClientMachine *Window::clientMachine() const +inline ClientMachine *Window::clientMachine() const { return m_clientMachine; } diff --git a/src/x11window.cpp b/src/x11window.cpp index 3ecb051282..95d0b94e6d 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -5118,4 +5118,64 @@ void X11Window::discardShapeRegion() m_shapeRegion.clear(); } +Xcb::Property X11Window::fetchWmClientLeader() const +{ + return Xcb::Property(false, window(), atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000); +} + +void X11Window::readWmClientLeader(Xcb::Property &prop) +{ + m_wmClientLeader = prop.value(window()); +} + +void X11Window::getWmClientLeader() +{ + auto prop = fetchWmClientLeader(); + readWmClientLeader(prop); +} + +/** + * Returns sessionId for this window, + * taken either from its window or from the leader window. + */ +QByteArray X11Window::sessionId() const +{ + QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id); + if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { + result = Xcb::StringProperty(m_wmClientLeader, atoms->sm_client_id); + } + return result; +} + +/** + * Returns command property for this window, + * taken either from its window or from the leader window. + */ +QString X11Window::wmCommand() +{ + QByteArray result = Xcb::StringProperty(window(), XCB_ATOM_WM_COMMAND); + if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { + result = Xcb::StringProperty(m_wmClientLeader, XCB_ATOM_WM_COMMAND); + } + result.replace(0, ' '); + return result; +} + +/** + * Returns client leader window for this client. + * Returns the client window itself if no leader window is defined. + */ +xcb_window_t X11Window::wmClientLeader() const +{ + if (m_wmClientLeader != XCB_WINDOW_NONE) { + return m_wmClientLeader; + } + return window(); +} + +void X11Window::getWmClientMachine() +{ + clientMachine()->resolve(window(), wmClientLeader()); +} + } // namespace diff --git a/src/x11window.h b/src/x11window.h index 1e64f41232..6d8b50bbd4 100644 --- a/src/x11window.h +++ b/src/x11window.h @@ -81,6 +81,10 @@ public: } xcb_window_t frameId() const override; + QByteArray sessionId() const; + xcb_window_t wmClientLeader() const; + QString wmCommand(); + QRectF inputGeometry() const override; QPointF framePosToClientPos(const QPointF &point) const override; @@ -363,6 +367,7 @@ private: QRect fullscreenMonitorsArea(NETFullscreenMonitors topology) const; void getResourceClass(); void getWmNormalHints(); + void getWmClientMachine(); void getMotifHints(); void getIcons(); void getWmOpaqueRegion(); @@ -373,6 +378,9 @@ private: void setCaption(const QString &s, bool force = false); bool hasTransientInternal(const X11Window *c, bool indirect, QList &set) const; void setShortcutInternal() override; + Xcb::Property fetchWmClientLeader() const; + void readWmClientLeader(Xcb::Property &p); + void getWmClientLeader(); void configureRequest(int value_mask, qreal rx, qreal ry, qreal rw, qreal rh, int gravity, bool from_tool); NETExtendedStrut strut() const; @@ -436,6 +444,7 @@ private: Xcb::Window m_client; Xcb::Window m_wrapper; Xcb::Window m_frame; + xcb_window_t m_wmClientLeader = XCB_WINDOW_NONE; int m_activityUpdatesBlocked; bool m_blockedActivityUpdatesRequireTransients; Xcb::Window m_moveResizeGrabWindow;