diff options
author | Jan Grulich <jgrulich@redhat.com> | 2022-01-11 15:38:08 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2022-11-09 12:19:16 +0100 |
commit | 807357873340b775c5535a5ead67c97161e43df0 (patch) | |
tree | 4a8d372f22ac5b0205deb7940d33cf71bfcdb866 | |
parent | 46481e846443b9347a774e66760ec9bc9b703782 (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
Change-Id: I4e7f6871b56599170b12e796858238b1df6d47d1
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit c0b0c7bebb73e1aa609196ce33668a54bd5e0aef)
-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 0ad9b199b0..5a1f707eef 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -109,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", 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() |