From a823366f7745c235a752dc01c42276b3fa410937 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 1 Nov 2022 14:57:33 +0100 Subject: Add QPlatformTheme::MouseCursorTheme and MouseCursorSize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also implement in QGenericUnixTheme/QKdeTheme/QGnomeTheme/QGtk3Theme. On Wayland, there is wl_cursor_theme_load() and etc in wayland-cursor.h. On X11/xcb, cursor theme and size are common, either in XCURSOR_THEME and XCURSOR_SIZE envs, or in gsettings for gtk/gnome world. On Windows, cursor theme is part of theme file, see SetWindowTheme in https://learn.microsoft.com/en-gb/windows/win32/api/uxtheme/nf-uxtheme-setwindowtheme . For system settings, for example on Windows 10, Mouse Settings, Additional mouse options, Pointers Tab, Scheme. On macOS, it looks like cursor theme is deprecated. Change-Id: I5821377d966c281fb8330da1f5baa7f0ddf86a9f Reviewed-by: Oliver Wolff Reviewed-by: Tor Arne Vestbø --- src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index 11fd492f60..22bf21c06b 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -101,6 +101,8 @@ QGtk3Theme::QGtk3Theme() SETTING_CONNECT("gtk-font-name"); SETTING_CONNECT("gtk-application-prefer-dark-theme"); SETTING_CONNECT("gtk-theme-name"); + SETTING_CONNECT("gtk-cursor-theme-name"); + SETTING_CONNECT("gtk-cursor-theme-size"); #undef SETTING_CONNECT /* Set XCURSOR_SIZE and XCURSOR_THEME for Wayland sessions */ @@ -150,6 +152,14 @@ QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(gtkSetting("gtk-icon-theme-name")); case QPlatformTheme::SystemIconFallbackThemeName: return QVariant(gtkSetting("gtk-fallback-icon-theme")); + case QPlatformTheme::MouseCursorTheme: + return QVariant(gtkSetting("gtk-cursor-theme-name")); + case QPlatformTheme::MouseCursorSize: { + int s = gtkSetting("gtk-cursor-theme-size"); + if (s > 0) + return QVariant(QSize(s, s)); + return QGnomeTheme::themeHint(hint); + } default: return QGnomeTheme::themeHint(hint); } -- cgit v1.2.3