Get Toplevel::resourceName() and ::resourceClass() from NETWinInfo
It's provided by the NETWinInfo, no need to keep an own implementation. To keep compatibility with existing KWin code using the window class or resource it's always converted to lower. In addition a notify signal Toplevel::windowClassChanged is added and emitted from the event handler whenever the WM2WindowClass property is set. REVIEW: 117496
This commit is contained in:
parent
b8cc10ffab
commit
c63e3533f4
5 changed files with 21 additions and 14 deletions
|
@ -523,6 +523,9 @@ bool Client::windowEvent(xcb_generic_event_t *e)
|
|||
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
||||
emit windowRoleChanged();
|
||||
}
|
||||
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
||||
getResourceClass();
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t eventType = e->response_type & ~0x80;
|
||||
|
@ -1508,6 +1511,9 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e)
|
|||
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
||||
emit windowRoleChanged();
|
||||
}
|
||||
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
||||
getResourceClass();
|
||||
}
|
||||
const uint8_t eventType = e->response_type & ~0x80;
|
||||
switch (eventType) {
|
||||
case XCB_UNMAP_NOTIFY:
|
||||
|
|
|
@ -91,6 +91,7 @@ bool Client::manage(xcb_window_t w, bool isMapped)
|
|||
NET::WMPid |
|
||||
NET::WMIconName;
|
||||
const NET::Properties2 properties2 =
|
||||
NET::WM2WindowClass |
|
||||
NET::WM2WindowRole |
|
||||
NET::WM2UserTime |
|
||||
NET::WM2StartupId |
|
||||
|
|
14
toplevel.cpp
14
toplevel.cpp
|
@ -224,17 +224,9 @@ Window Toplevel::wmClientLeader() const
|
|||
|
||||
void Toplevel::getResourceClass()
|
||||
{
|
||||
XClassHint classHint;
|
||||
if (XGetClassHint(display(), window(), &classHint)) {
|
||||
// Qt3.2 and older had this all lowercase, Qt3.3 capitalized resource class.
|
||||
// Force lowercase, so that workarounds listing resource classes still work.
|
||||
resource_name = QByteArray(classHint.res_name).toLower();
|
||||
resource_class = QByteArray(classHint.res_class).toLower();
|
||||
XFree(classHint.res_name);
|
||||
XFree(classHint.res_class);
|
||||
} else {
|
||||
resource_name = resource_class = QByteArray();
|
||||
}
|
||||
resource_name = QByteArray(info->windowClassName()).toLower();
|
||||
resource_class = QByteArray(info->windowClassClass()).toLower();
|
||||
emit windowClassChanged();
|
||||
}
|
||||
|
||||
double Toplevel::opacity() const
|
||||
|
|
|
@ -73,8 +73,8 @@ class Toplevel
|
|||
Q_PROPERTY(QRect rect READ rect)
|
||||
Q_PROPERTY(QPoint clientPos READ clientPos)
|
||||
Q_PROPERTY(QSize clientSize READ clientSize)
|
||||
Q_PROPERTY(QByteArray resourceName READ resourceName)
|
||||
Q_PROPERTY(QByteArray resourceClass READ resourceClass)
|
||||
Q_PROPERTY(QByteArray resourceName READ resourceName NOTIFY windowClassChanged)
|
||||
Q_PROPERTY(QByteArray resourceClass READ resourceClass NOTIFY windowClassChanged)
|
||||
Q_PROPERTY(QByteArray windowRole READ windowRole NOTIFY windowRoleChanged)
|
||||
/**
|
||||
* Returns whether the window is a desktop background window (the one with wallpaper).
|
||||
|
@ -372,6 +372,11 @@ Q_SIGNALS:
|
|||
* @since 5.0
|
||||
**/
|
||||
void windowRoleChanged();
|
||||
/**
|
||||
* Emitted whenever the window class name or resource name of the window changes.
|
||||
* @since 5.0
|
||||
**/
|
||||
void windowClassChanged();
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,10 @@ 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::WM2WindowRole);
|
||||
NET::WMWindowType | NET::WMPid,
|
||||
NET::WM2Opacity |
|
||||
NET::WM2WindowRole |
|
||||
NET::WM2WindowClass);
|
||||
getResourceClass();
|
||||
getWmClientLeader();
|
||||
getWmClientMachine();
|
||||
|
|
Loading…
Reference in a new issue