diff options
author | Jan Grulich <jgrulich@redhat.com> | 2022-01-11 15:38:08 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2022-11-08 13:42:27 +0100 |
commit | c0b0c7bebb73e1aa609196ce33668a54bd5e0aef (patch) | |
tree | 5992be29af2c6df3ba14e4ca3e4f7bb0f20f45d1 /src/plugins | |
parent | 02b9033d50def3b4c70a4f0504b5894d4249be1b (diff) |
Gtk3Theme: set XCURSOR_SIZE and XCURSOR_THEME for wayland sessions
GNOME doesn't set these for Wayland session and without those env
variables set users might experience broken cursor with Qt apps
as QWayland reads them to setup QWaylandInputDevice.
There is no cursor protocol available on Wayland yet, see also
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/58
Qt Wayland QPA plugin still tries to load from those two envs.
Fixes: QTBUG-67579
Fixes: QTBUG-87778
Pick-to: 6.4 6.2 5.15
Change-Id: I4e7f6871b56599170b12e796858238b1df6d47d1
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index c2bc49af47..313fd40b9f 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -102,6 +102,20 @@ QGtk3Theme::QGtk3Theme() SETTING_CONNECT("gtk-application-prefer-dark-theme"); SETTING_CONNECT("gtk-theme-name"); #undef SETTING_CONNECT + + /* Set XCURSOR_SIZE and XCURSOR_THEME for Wayland sessions */ + if (QGuiApplication::platformName().startsWith("wayland"_L1)) { + if (qEnvironmentVariableIsEmpty("XCURSOR_SIZE")) { + const int cursorSize = gtkSetting<gint>("gtk-cursor-theme-size"); + if (cursorSize > 0) + qputenv("XCURSOR_SIZE", QString::number(cursorSize).toUtf8()); + } + if (qEnvironmentVariableIsEmpty("XCURSOR_THEME")) { + const QString cursorTheme = gtkSetting("gtk-cursor-theme-name"); + if (!cursorTheme.isEmpty()) + qputenv("XCURSOR_THEME", cursorTheme.toUtf8()); + } + } } static inline QVariant gtkGetLongPressTime() |