summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-22 14:39:17 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-22 17:12:16 (GMT)
commit57cc5c50df4fc3673c948e8a55b4bab991e9cb7f (patch)
tree9609fdf3fb3def986a662be85ed41c5876677e11 /src
parent9f08d620588752a6617d0e265c6b7137704e39c5 (diff)
downloadQt-57cc5c50df4fc3673c948e8a55b4bab991e9cb7f.zip
Qt-57cc5c50df4fc3673c948e8a55b4bab991e9cb7f.tar.gz
Qt-57cc5c50df4fc3673c948e8a55b4bab991e9cb7f.tar.bz2
clean up x11 desktop detection
KDE_FULL_SESSION is reliable since kde 2.x or so. DESKTOP_SESSION is not reliable, unless one uses a new gnome. GNOME_DESKTOP_SESSION_ID was temporarily unreliable. the two together should be reliable. copy the xfce4 detection from the xdg-open tool. assumed to be reliable. remove the window manager hacks, as they are redundand with the asssumedly reliable detection methods above. Reviewed-by: jbache
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qapplication_x11.cpp116
-rw-r--r--src/gui/kernel/qt_x11_p.h5
2 files changed, 31 insertions, 90 deletions
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 34865b5..c6e192b 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -208,11 +208,8 @@ static const char * x11_atomnames = {
"_MOTIF_WM_HINTS\0"
"DTWM_IS_RUNNING\0"
- "KDE_FULL_SESSION\0"
- "KWIN_RUNNING\0"
- "KWM_RUNNING\0"
- "GNOME_BACKGROUND_PROPERTIES\0"
"ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
"_SGI_DESKS_MANAGER\0"
// EWMH (aka NETWM)
@@ -626,8 +623,6 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
|| err->resourceid == XA_RGB_DEFAULT_MAP
|| err->resourceid == ATOM(_NET_SUPPORTED)
|| err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
- || err->resourceid == ATOM(KDE_FULL_SESSION)
- || err->resourceid == ATOM(KWIN_RUNNING)
|| err->resourceid == ATOM(XdndProxy)
|| err->resourceid == ATOM(XdndAware))) {
// Perhaps we're running under SECURITY reduction? :/
@@ -2222,87 +2217,36 @@ void qt_init(QApplicationPrivate *priv, int,
X11->desktopEnvironment = DE_UNKNOWN;
X11->desktopVersion = 0;
- // See if the current window manager is using the freedesktop.org spec to give its name
- Window windowManagerWindow = XNone;
- Atom typeReturned;
- int formatReturned;
- unsigned long nitemsReturned;
- unsigned long unused;
- unsigned char *data = 0;
- if (XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(),
- ATOM(_NET_SUPPORTING_WM_CHECK),
- 0, 1024, False, XA_WINDOW, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == XA_WINDOW && formatReturned == 32)
- windowManagerWindow = *((Window*) data);
- if (data)
- XFree(data);
-
- if (windowManagerWindow != XNone) {
- QString wmName;
- Atom utf8atom = ATOM(UTF8_STRING);
- if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME),
- 0, 1024, False, utf8atom, &typeReturned,
- &formatReturned, &nitemsReturned, &unused, &data)
- == Success) {
- if (typeReturned == utf8atom && formatReturned == 8)
- wmName = QString::fromUtf8((const char*)data);
- if (data)
- XFree(data);
- if (wmName == QLatin1String("KWin"))
- X11->desktopEnvironment = DE_KDE;
- if (wmName == QLatin1String("Metacity"))
- X11->desktopEnvironment = DE_GNOME;
- }
- }
- }
-
- // Running a different/newer/older window manager? Try some other things
- if (X11->desktopEnvironment == DE_UNKNOWN){
- Atom type;
- int format;
- unsigned long length, after;
- uchar *data = 0;
-
- QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
- if (session == QLatin1String("kde")) {
- X11->desktopEnvironment = DE_KDE;
- } else if (session == QLatin1String("gnome") || session == QLatin1String("xfce")) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length) {
- // DTWM is running, meaning most likely CDE is running...
- X11->desktopEnvironment = DE_CDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(),
- ATOM(GNOME_BACKGROUND_PROPERTIES), 0, 1, False, AnyPropertyType,
- &type, &format, &length, &after, &data) == Success && length) {
- X11->desktopEnvironment = DE_GNOME;
- } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) {
- X11->desktopEnvironment = DE_GNOME;
- } else if ((XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KDE_FULL_SESSION),
- 0, 1, False, AnyPropertyType, &type, &format, &length, &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWIN_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success
- && length)
- || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWM_RUNNING),
- 0, 1, False, AnyPropertyType, &type, &format, &length,
- &after, &data) == Success && length)) {
- X11->desktopEnvironment = DE_KDE;
- } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
- 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
- && length) {
- X11->desktopEnvironment = DE_4DWM;
- }
- if (data)
- XFree((char *)data);
+ Atom type;
+ int format;
+ unsigned long length, after;
+ uchar *data = 0;
+
+ if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
+ X11->desktopEnvironment = DE_KDE;
+ X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt();
+ } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() // Deprecated for some reason.
+ || qgetenv("DESKTOP_SESSION") == "gnome") { // De-facto-standardized by GNOME.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE),
+ 0, 2, False, XA_STRING, &type, &format, &length,
+ &after, &data) == Success
+ && !strcmp(reinterpret_cast<char *>(data), "xfce4")) {
+ // Pretend that xfce4 is gnome, as it uses the same libraries.
+ // The detection above is stolen from xdg-open.
+ X11->desktopEnvironment = DE_GNOME;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING),
+ 0, 1, False, AnyPropertyType, &type, &format, &length,
+ &after, &data) == Success && length) {
+ // DTWM is running, meaning most likely CDE is running...
+ X11->desktopEnvironment = DE_CDE;
+ } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER),
+ 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success
+ && length) {
+ X11->desktopEnvironment = DE_4DWM;
}
-
- if (X11->desktopEnvironment == DE_KDE)
- X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
+ if (data)
+ XFree((char *)data);
#if !defined(QT_NO_STYLE_GTK)
if (X11->desktopEnvironment == DE_GNOME) {
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index b2ce754..167557b 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -564,11 +564,8 @@ struct QX11Data
_MOTIF_WM_HINTS,
DTWM_IS_RUNNING,
- KDE_FULL_SESSION,
- KWIN_RUNNING,
- KWM_RUNNING,
- GNOME_BACKGROUND_PROPERTIES,
ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
_SGI_DESKS_MANAGER,
// EWMH (aka NETWM)