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.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
index 8551966678..1f912aaf26 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
@@ -7,6 +7,7 @@
#include <QVariant>
#include <QtCore/qregularexpression.h>
#include <QGuiApplication>
+#include <qpa/qwindowsysteminterface.h>
#undef signals
#include <gtk/gtk.h>
@@ -82,6 +83,39 @@ QGtk3Theme::QGtk3Theme()
/* Use our custom log handler. */
g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, nullptr);
+
+#define SETTING_CONNECT(setting) g_signal_connect(settings, "notify::" setting, G_CALLBACK(notifyThemeChanged), nullptr)
+ auto notifyThemeChanged = [] {
+ QWindowSystemInterface::handleThemeChange();
+ };
+
+ GtkSettings *settings = gtk_settings_get_default();
+ SETTING_CONNECT("gtk-cursor-blink-time");
+ SETTING_CONNECT("gtk-double-click-distance");
+ SETTING_CONNECT("gtk-double-click-time");
+ SETTING_CONNECT("gtk-long-press-time");
+ SETTING_CONNECT("gtk-entry-password-hint-timeout");
+ SETTING_CONNECT("gtk-dnd-drag-threshold");
+ SETTING_CONNECT("gtk-icon-theme-name");
+ SETTING_CONNECT("gtk-fallback-icon-theme");
+ SETTING_CONNECT("gtk-font-name");
+ 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", 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()
@@ -116,8 +150,6 @@ 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::PreselectFirstFileInDirectory:
- return true;
default:
return QGnomeTheme::themeHint(hint);
}
@@ -158,7 +190,7 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
gtk-theme-name provides both light and dark variants. We can save a
regex check by testing this property first.
*/
- const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
+ const auto preferDark = gtkSetting<gboolean>("gtk-application-prefer-dark-theme");
if (preferDark)
return Appearance::Dark;