From f1f6d6eea88113513bcd1fcf55616e9bbde19b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 10 Apr 2014 11:12:48 +0200 Subject: [PATCH] Get windowRole from NETWinInfo instead doing it ourself NETWinInfo provides windowRole if NET::WM2WindowRole is added to the properties2. Thus KWin doesn't need to monitor and fetch itself, but can just wrap the data provided by NETWinInfo. In addition a signal is added to Toplevel whenever the window role changes. REVIEW: 117470 --- events.cpp | 8 ++++++-- manage.cpp | 2 +- toplevel.cpp | 6 ------ toplevel.h | 11 +++++++---- unmanaged.cpp | 3 +-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/events.cpp b/events.cpp index 26169a000c..43ef8176e8 100644 --- a/events.cpp +++ b/events.cpp @@ -520,6 +520,9 @@ bool Client::windowEvent(xcb_generic_event_t *e) if (dirtyProperties2 & NET::WM2FrameOverlap) { // ### Inform the decoration } + if (dirtyProperties2.testFlag(NET::WM2WindowRole)) { + emit windowRoleChanged(); + } } const uint8_t eventType = e->response_type & ~0x80; @@ -1502,6 +1505,9 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) emit opacityChanged(this, old_opacity); } } + if (dirtyProperties2.testFlag(NET::WM2WindowRole)) { + emit windowRoleChanged(); + } const uint8_t eventType = e->response_type & ~0x80; switch (eventType) { case XCB_UNMAP_NOTIFY: @@ -1558,8 +1564,6 @@ void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e) default: if (e->atom == atoms->wm_client_leader) getWmClientLeader(); - else if (e->atom == atoms->wm_window_role) - getWindowRole(); else if (e->atom == atoms->kde_net_wm_shadow) getShadow(); else if (e->atom == atoms->net_wm_opaque_region) diff --git a/manage.cpp b/manage.cpp index d8bd190b91..393b826549 100644 --- a/manage.cpp +++ b/manage.cpp @@ -91,6 +91,7 @@ bool Client::manage(xcb_window_t w, bool isMapped) NET::WMPid | NET::WMIconName; const NET::Properties2 properties2 = + NET::WM2WindowRole | NET::WM2UserTime | NET::WM2StartupId | NET::WM2ExtendedStrut | @@ -103,7 +104,6 @@ bool Client::manage(xcb_window_t w, bool isMapped) m_colormap = attr.colormap; getResourceClass(); - getWindowRole(); getWmClientLeader(); getWmClientMachine(); getSyncCounter(); diff --git a/toplevel.cpp b/toplevel.cpp index eac6890ae1..fe69256c5c 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -124,7 +124,6 @@ void Toplevel::copyToDeleted(Toplevel* c) m_clientMachine = c->m_clientMachine; m_clientMachine->setParent(this); wmClientLeaderWin = c->wmClientLeader(); - window_role = c->windowRole(); opaque_region = c->opaqueRegion(); m_screen = c->m_screen; m_skipCloseAnimation = c->m_skipCloseAnimation; @@ -146,11 +145,6 @@ QRect Toplevel::visibleRect() const return r.translated(geometry().topLeft()); } -void Toplevel::getWindowRole() -{ - window_role = getStringProperty(window(), atoms->wm_window_role).toLower(); -} - /*! Returns SM_CLIENT_ID property for a given window. */ diff --git a/toplevel.h b/toplevel.h index f8a05bead8..7e7725cd2a 100644 --- a/toplevel.h +++ b/toplevel.h @@ -75,7 +75,7 @@ class Toplevel Q_PROPERTY(QSize clientSize READ clientSize) Q_PROPERTY(QByteArray resourceName READ resourceName) Q_PROPERTY(QByteArray resourceClass READ resourceClass) - Q_PROPERTY(QByteArray windowRole READ windowRole) + Q_PROPERTY(QByteArray windowRole READ windowRole NOTIFY windowRoleChanged) /** * Returns whether the window is a desktop background window (the one with wallpaper). * See _NET_WM_WINDOW_TYPE_DESKTOP at http://standards.freedesktop.org/wm-spec/wm-spec-latest.html . @@ -367,6 +367,11 @@ Q_SIGNALS: **/ void screenChanged(); void skipCloseAnimationChanged(); + /** + * Emitted whenever the window role of the window changes. + * @since 5.0 + **/ + void windowRoleChanged(); protected Q_SLOTS: /** @@ -400,7 +405,6 @@ protected: void getWmOpaqueRegion(); void getResourceClass(); - void getWindowRole(); void getSkipCloseAnimation(); virtual void debug(QDebug& stream) const = 0; void copyToDeleted(Toplevel* c); @@ -433,7 +437,6 @@ private: QByteArray resource_class; ClientMachine *m_clientMachine; WId wmClientLeaderWin; - QByteArray window_role; bool unredirect; bool unredirectSuspend; // when unredirected, but pixmap is needed temporarily bool m_damageReplyPending; @@ -659,7 +662,7 @@ inline QByteArray Toplevel::resourceClass() const inline QByteArray Toplevel::windowRole() const { - return window_role; + return QByteArray(info->windowRole()); } inline bool Toplevel::unredirected() const diff --git a/unmanaged.cpp b/unmanaged.cpp index 863f8a6e57..e0e757914f 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -65,9 +65,8 @@ bool Unmanaged::track(Window w) vis = attr.visual; bit_depth = attr.depth; info = new NETWinInfo(connection(), w, rootWindow(), - NET::WMWindowType | NET::WMPid, NET::WM2Opacity); + NET::WMWindowType | NET::WMPid, NET::WM2Opacity | NET::WM2WindowRole); getResourceClass(); - getWindowRole(); getWmClientLeader(); getWmClientMachine(); if (Xcb::Extensions::self()->isShapeAvailable())