summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platformthemes/gtk3/qgtk3theme.cpp')
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3theme.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
index 93520344f8..03f19a5b70 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
@@ -41,6 +41,7 @@
#include "qgtk3dialoghelpers.h"
#include "qgtk3menu.h"
#include <QVariant>
+#include <QGuiApplication>
#undef signals
#include <gtk/gtk.h>
@@ -84,6 +85,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);
@@ -100,6 +109,20 @@ QGtk3Theme::QGtk3Theme()
/* Use our custom log handler. */
g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, nullptr);
+
+ /* Set XCURSOR_SIZE and XCURSOR_THEME for Wayland sessions */
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
+ if (qEnvironmentVariableIsEmpty("XCURSOR_SIZE")) {
+ const int cursorSize = gtkSetting<gint>("gtk-cursor-theme-size");
+ if (cursorSize > 0)
+ qputenv("XCURSOR_SIZE", QByteArray::number(cursorSize));
+ }
+ if (qEnvironmentVariableIsEmpty("XCURSOR_THEME")) {
+ const QString cursorTheme = gtkSetting("gtk-cursor-theme-name");
+ if (!cursorTheme.isEmpty())
+ qputenv("XCURSOR_THEME", cursorTheme.toUtf8());
+ }
+ }
}
static inline QVariant gtkGetLongPressTime()