From 687e264387170c45d02d451ba71426645973c037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 9 Sep 2013 05:08:58 +0200 Subject: [PATCH] Port staticWmClientLeader to XCB Removes usage of kxerrorhandler in kwin/toplevel.cpp --- toplevel.cpp | 25 +++++++------------------ toplevel.h | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/toplevel.cpp b/toplevel.cpp index 9eee8bafea..f7be70bb25 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -20,8 +20,6 @@ along with this program. If not, see . #include "toplevel.h" -#include - #ifdef KWIN_BUILD_ACTIVITIES #include "activities.h" #endif @@ -172,24 +170,15 @@ QByteArray Toplevel::staticWmCommand(WId w) /*! Returns WM_CLIENT_LEADER property for a given window. */ -Window Toplevel::staticWmClientLeader(WId w) +xcb_window_t Toplevel::staticWmClientLeader(xcb_window_t w) { - Atom type; - int format, status; - unsigned long nitems = 0; - unsigned long extra = 0; - unsigned char *data = 0; - Window result = w; - KXErrorHandler err; - status = XGetWindowProperty(display(), w, atoms->wm_client_leader, 0, 10000, - false, XA_WINDOW, &type, &format, - &nitems, &extra, &data); - if (status == Success && !err.error(false)) { - if (data && nitems > 0) - result = *((Window*) data); - XFree(data); + xcb_connection_t *c = connection(); + auto cookie = xcb_get_property_unchecked(c, false, w, atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000); + ScopedCPointer prop(xcb_get_property_reply(c, cookie, nullptr)); + if (prop.isNull() || prop->value_len <= 0) { + return w; } - return result; + return static_cast(xcb_get_property_value(prop.data()))[0]; } diff --git a/toplevel.h b/toplevel.h index d8f1a84394..83078459db 100644 --- a/toplevel.h +++ b/toplevel.h @@ -389,7 +389,7 @@ private: static QByteArray staticSessionId(WId); static QByteArray staticWmCommand(WId); static QByteArray staticWmClientMachine(WId); - static Window staticWmClientLeader(WId); + static xcb_window_t staticWmClientLeader(xcb_window_t); // when adding new data members, check also copyToDeleted() Window client; Window frame;