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
This commit is contained in:
Martin Gräßlin 2014-04-10 11:12:48 +02:00
parent cf498cc14b
commit f1f6d6eea8
5 changed files with 15 additions and 15 deletions

View file

@ -520,6 +520,9 @@ bool Client::windowEvent(xcb_generic_event_t *e)
if (dirtyProperties2 & NET::WM2FrameOverlap) { if (dirtyProperties2 & NET::WM2FrameOverlap) {
// ### Inform the decoration // ### Inform the decoration
} }
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
emit windowRoleChanged();
}
} }
const uint8_t eventType = e->response_type & ~0x80; 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); emit opacityChanged(this, old_opacity);
} }
} }
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
emit windowRoleChanged();
}
const uint8_t eventType = e->response_type & ~0x80; const uint8_t eventType = e->response_type & ~0x80;
switch (eventType) { switch (eventType) {
case XCB_UNMAP_NOTIFY: case XCB_UNMAP_NOTIFY:
@ -1558,8 +1564,6 @@ void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
default: default:
if (e->atom == atoms->wm_client_leader) if (e->atom == atoms->wm_client_leader)
getWmClientLeader(); getWmClientLeader();
else if (e->atom == atoms->wm_window_role)
getWindowRole();
else if (e->atom == atoms->kde_net_wm_shadow) else if (e->atom == atoms->kde_net_wm_shadow)
getShadow(); getShadow();
else if (e->atom == atoms->net_wm_opaque_region) else if (e->atom == atoms->net_wm_opaque_region)

View file

@ -91,6 +91,7 @@ bool Client::manage(xcb_window_t w, bool isMapped)
NET::WMPid | NET::WMPid |
NET::WMIconName; NET::WMIconName;
const NET::Properties2 properties2 = const NET::Properties2 properties2 =
NET::WM2WindowRole |
NET::WM2UserTime | NET::WM2UserTime |
NET::WM2StartupId | NET::WM2StartupId |
NET::WM2ExtendedStrut | NET::WM2ExtendedStrut |
@ -103,7 +104,6 @@ bool Client::manage(xcb_window_t w, bool isMapped)
m_colormap = attr.colormap; m_colormap = attr.colormap;
getResourceClass(); getResourceClass();
getWindowRole();
getWmClientLeader(); getWmClientLeader();
getWmClientMachine(); getWmClientMachine();
getSyncCounter(); getSyncCounter();

View file

@ -124,7 +124,6 @@ void Toplevel::copyToDeleted(Toplevel* c)
m_clientMachine = c->m_clientMachine; m_clientMachine = c->m_clientMachine;
m_clientMachine->setParent(this); m_clientMachine->setParent(this);
wmClientLeaderWin = c->wmClientLeader(); wmClientLeaderWin = c->wmClientLeader();
window_role = c->windowRole();
opaque_region = c->opaqueRegion(); opaque_region = c->opaqueRegion();
m_screen = c->m_screen; m_screen = c->m_screen;
m_skipCloseAnimation = c->m_skipCloseAnimation; m_skipCloseAnimation = c->m_skipCloseAnimation;
@ -146,11 +145,6 @@ QRect Toplevel::visibleRect() const
return r.translated(geometry().topLeft()); 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. Returns SM_CLIENT_ID property for a given window.
*/ */

View file

@ -75,7 +75,7 @@ class Toplevel
Q_PROPERTY(QSize clientSize READ clientSize) Q_PROPERTY(QSize clientSize READ clientSize)
Q_PROPERTY(QByteArray resourceName READ resourceName) Q_PROPERTY(QByteArray resourceName READ resourceName)
Q_PROPERTY(QByteArray resourceClass READ resourceClass) 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). * 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 . * 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 screenChanged();
void skipCloseAnimationChanged(); void skipCloseAnimationChanged();
/**
* Emitted whenever the window role of the window changes.
* @since 5.0
**/
void windowRoleChanged();
protected Q_SLOTS: protected Q_SLOTS:
/** /**
@ -400,7 +405,6 @@ protected:
void getWmOpaqueRegion(); void getWmOpaqueRegion();
void getResourceClass(); void getResourceClass();
void getWindowRole();
void getSkipCloseAnimation(); void getSkipCloseAnimation();
virtual void debug(QDebug& stream) const = 0; virtual void debug(QDebug& stream) const = 0;
void copyToDeleted(Toplevel* c); void copyToDeleted(Toplevel* c);
@ -433,7 +437,6 @@ private:
QByteArray resource_class; QByteArray resource_class;
ClientMachine *m_clientMachine; ClientMachine *m_clientMachine;
WId wmClientLeaderWin; WId wmClientLeaderWin;
QByteArray window_role;
bool unredirect; bool unredirect;
bool unredirectSuspend; // when unredirected, but pixmap is needed temporarily bool unredirectSuspend; // when unredirected, but pixmap is needed temporarily
bool m_damageReplyPending; bool m_damageReplyPending;
@ -659,7 +662,7 @@ inline QByteArray Toplevel::resourceClass() const
inline QByteArray Toplevel::windowRole() const inline QByteArray Toplevel::windowRole() const
{ {
return window_role; return QByteArray(info->windowRole());
} }
inline bool Toplevel::unredirected() const inline bool Toplevel::unredirected() const

View file

@ -65,9 +65,8 @@ bool Unmanaged::track(Window w)
vis = attr.visual; vis = attr.visual;
bit_depth = attr.depth; bit_depth = attr.depth;
info = new NETWinInfo(connection(), w, rootWindow(), info = new NETWinInfo(connection(), w, rootWindow(),
NET::WMWindowType | NET::WMPid, NET::WM2Opacity); NET::WMWindowType | NET::WMPid, NET::WM2Opacity | NET::WM2WindowRole);
getResourceClass(); getResourceClass();
getWindowRole();
getWmClientLeader(); getWmClientLeader();
getWmClientMachine(); getWmClientMachine();
if (Xcb::Extensions::self()->isShapeAvailable()) if (Xcb::Extensions::self()->isShapeAvailable())