Package: qt4-x11
Version: 4:4.8.7+dfsg-7
Severity: wishlist
Tags: upstream patch

Hi,

Qt4 applications are smart enough to detect when they're run under GNOME
or XFCE, and use the GTK+ theme unless configured otherwise, thanks to a
bunch of tests that determine which desktop the application is running on.

Unfortunately, these tests don't include the MATE desktop; Qt5 does
include such a test, but a lot of applications still use Qt4 (for
example, on my system, I have avidemux, bitcoin-qt, clementine, and
skype which depend on Qt4 libs).

To determine if GNOME 2 is running, Qt4 checks for the presence of an
environment variable named GNOME_DESKTOP_SESSION_ID (which is said to be
deprecated, but Qt4 acknowledges this fact in its comments and still
uses it nevertheless). Since MATE is a fork of GNOME 2, it sets an
equivalent variable named MATE_DESKTOP_SESSION_ID, so I wrote a small
patch that simply duplicates the test with the new variable name.

I'm sure it could be made more elegant and check for both variables
names within the same test, but since I'm no C coder, I didn't want to
mess with the code so I chose the safe path. If you can rework the patch
in this way, this would be even better; the basic idea is to check for
MATE_DESKTOP_SESSION_ID (like the GNOME 2 test does) and if found,
pretend we're under GNOME (like the XFCE test does).

Anyway, here's the patch. I compiled Qt4 packages with it for my
personal use and they work as expected: Qt4 applications now use the
GTK+ theme natively when run under MATE, without any specific user
configuration (I removed ~/.config/Trolltech.conf to test that), whereas
with the unpatched version, it used to fall back on the "Default" (in
qt4-qtconfig) theme (the one which looks like Windows 9x).

Regards,

-- 
Raphaël Halimi
Description: Add support for MATE desktop
 This patch checks for an environment variable set by MATE desktop, in order to
 make Qt4 applications natively use the GTK+ style when run on this desktop
Author: Raphaël Halimi <raphael.hal...@gmail.com>
Origin: other
Last-Update: 2016-05-29
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2361,6 +2361,12 @@
                 break;
             }
 
+            // Check the equivalent environment variable set by MATE
+            if (!qgetenv("MATE_DESKTOP_SESSION_ID").isEmpty()) {
+                X11->desktopEnvironment = DE_GNOME;
+                break;
+            }
+
             rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE),
                                     0, 2, False, XA_STRING, &type, &format, &length,
                                     &after, &data);

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to