diff options
Diffstat (limited to 'src/corelib/core/mcomponentdata.cpp')
-rw-r--r-- | src/corelib/core/mcomponentdata.cpp | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp index 3ed19820..4a174c17 100644 --- a/src/corelib/core/mcomponentdata.cpp +++ b/src/corelib/core/mcomponentdata.cpp @@ -56,10 +56,12 @@ #include "mgraphicssystemhelper.h" #ifdef Q_WS_X11 -#ifdef HAVE_XDAMAGE #include <QX11Info> +#include <X11/Xlib.h> +#include <X11/Xatom.h> +#ifdef HAVE_XDAMAGE #include <X11/extensions/Xfixes.h> -#endif // HAVE_XFIXES +#endif // HAVE_XDAMAGE #endif // Q_WS_X11 namespace @@ -1172,6 +1174,62 @@ bool MComponentData::isOrientationForced() } #ifdef Q_WS_X11 +static int handleXError(Display *, XErrorEvent *) +{ + return 0; +} +#endif // Q_WS_X11 + +bool MComponentData::isMeeGoWindowManagerRunning() +{ + bool retValue = false; + +#ifdef Q_WS_X11 + + Display *dpy = QX11Info::display(); + Window rootw = RootWindow(dpy, XDefaultScreen(dpy)); + Atom wmSupportAtom = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); + Atom type; + int format; + unsigned long numItems; + unsigned long bytesAfter; + unsigned char *data = 0; + + if (XGetWindowProperty(dpy, rootw, wmSupportAtom, 0, 1, False, XA_WINDOW, + &type, &format, &numItems, &bytesAfter, &data) == Success) { + if (data) { + + Window wid = *(reinterpret_cast<Window *>(data)); + XFree(data); + data = 0; + + Atom wmNameAtom = XInternAtom(dpy, "WM_NAME", False); + + // Set error handler because window wid we got might not exist and + // the following name query would fail. + int (*previousHandler)(Display *, XErrorEvent *) = XSetErrorHandler(handleXError); + + if (XGetWindowProperty(dpy, wid, wmNameAtom, 0, 16, False, XA_STRING, + &type, &format, &numItems, &bytesAfter, &data) == Success) { + if (data) { + if (strcmp(reinterpret_cast<const char *>(data), "MCompositor") == 0) { + retValue = true; + } + + XFree(data); + data = 0; + } + } + + XSetErrorHandler(previousHandler); + } + } +#endif // Q_WS_X11 + + return retValue; +} + +#ifdef Q_WS_X11 QStack<MComponentData::ChainData> MComponentDataPrivate::chainData; void MComponentData::pushChainData(const ChainData &newChainData) |