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
icc-effect-5.14.5
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) {
// ### 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)

View File

@ -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();

View File

@ -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.
*/

View File

@ -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

View File

@ -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())