From b3d4dbdbf164e4a23b6e3e3a3ed800c9f74c9108 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 5 Dec 2022 11:52:17 -0300 Subject: [PATCH] frames/window-tracker: Reinstate dark titlebar support Merge request !2541 [1] introduced support for integrating Mutter frames with the dark style. This was lost after moving frames into a separate client. Bring that back. Don't depend on gdesktop-enums as it brings GTK3 into the header chain. [1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2541 Part-of: --- src/frames/meson.build | 1 + src/frames/meta-window-tracker.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/frames/meson.build b/src/frames/meson.build index 8c00996c0..b4c879050 100644 --- a/src/frames/meson.build +++ b/src/frames/meson.build @@ -9,6 +9,7 @@ x11_frames_sources = [ x11_frames = executable('mutter-x11-frames', sources: x11_frames_sources, dependencies: [ + gsettings_desktop_schemas_dep, gtk4_dep, x11_dep, xext_dep, diff --git a/src/frames/meta-window-tracker.c b/src/frames/meta-window-tracker.c index f849c547d..34c02a6b7 100644 --- a/src/frames/meta-window-tracker.c +++ b/src/frames/meta-window-tracker.c @@ -23,6 +23,7 @@ #include "meta-frame.h" +#include #include #include #include @@ -30,6 +31,9 @@ struct _MetaWindowTracker { GObject parent_instance; + + GSettings *interface_settings; + GdkDisplay *display; GHashTable *frames; GHashTable *client_windows; @@ -84,6 +88,23 @@ meta_window_tracker_get_property (GObject *object, } } +static void +on_color_scheme_changed_cb (GSettings *interface_settings, + GParamSpec *pspec, + MetaWindowTracker *window_tracker) +{ + GDesktopColorScheme color_scheme; + gboolean is_dark; + + color_scheme = g_settings_get_enum (window_tracker->interface_settings, + "color-scheme"); + is_dark = color_scheme == G_DESKTOP_COLOR_SCHEME_PREFER_DARK; + + g_object_set (gtk_settings_get_default (), + "gtk-application-prefer-dark-theme", is_dark, + NULL); +} + static void set_up_frame (MetaWindowTracker *window_tracker, Window xwindow) @@ -346,6 +367,7 @@ meta_window_tracker_finalize (GObject *object) { MetaWindowTracker *window_tracker = META_WINDOW_TRACKER (object); + g_clear_object (&window_tracker->interface_settings); g_clear_pointer (&window_tracker->frames, g_hash_table_unref); g_clear_pointer (&window_tracker->client_windows, @@ -382,6 +404,12 @@ meta_window_tracker_class_init (MetaWindowTrackerClass *klass) static void meta_window_tracker_init (MetaWindowTracker *window_tracker) { + window_tracker->interface_settings = g_settings_new ("org.gnome.desktop.interface"); + g_signal_connect (window_tracker->interface_settings, + "changed::color-scheme", + G_CALLBACK (on_color_scheme_changed_cb), + window_tracker); + window_tracker->frames = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) gtk_window_destroy);