summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2022-07-02 13:56:00 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2022-08-01 12:41:44 +0400
commitf608e39c727af6ca94ffb3662e71f218aac11080 (patch)
tree2f97d5565c9a58064d53bbaf63e5f9c5cc2a10e9
parent42b55f34694fe9200c299685312fdea17b3d0b3d (diff)
QGtk3Theme: Ensure gtk uses the same windowing system as Qt
Fixes: QTBUG-69354 Change-Id: I254c5bf98bc3b2cc2577159e475a2105438bb96b Reviewed-by: Liang Qi <liang.qi@qt.io> (cherry picked from commit 3d45f23b022878444454ec1a47c25678b88868c6)
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3theme.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
index a47720384c..484f20802e 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
@@ -42,6 +42,7 @@
#include "qgtk3menu.h"
#include <QVariant>
#include <QtCore/qregularexpression.h>
+#include <QGuiApplication>
#undef signals
#include <gtk/gtk.h>
@@ -85,6 +86,14 @@ void gtkMessageHandler(const gchar *log_domain,
QGtk3Theme::QGtk3Theme()
{
+ // Ensure gtk uses the same windowing system, but let it
+ // fallback in case GDK_BACKEND environment variable
+ // filters the preferred one out
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland")))
+ gdk_set_allowed_backends("wayland,x11");
+ else if (QGuiApplication::platformName() == QLatin1String("xcb"))
+ gdk_set_allowed_backends("x11,wayland");
+
// gtk_init will reset the Xlib error handler, and that causes
// Qt applications to quit on X errors. Therefore, we need to manually restore it.
int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(nullptr);