mirror of
https://github.com/brl/mutter.git
synced 2025-04-08 19:29:39 +00:00
frames: Add basic color-scheme support
Use the dark variant for decorations if the color-scheme preference indicates that it's preferred, and the client didn't explicitly pick a variant via the _GTK_THEME_VARIANT hint. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2541>
This commit is contained in:
parent
7c8ffe7efe
commit
9d4aa4488a
@ -26,6 +26,7 @@
|
|||||||
#include <cairo-xlib.h>
|
#include <cairo-xlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <gdesktop-enums.h>
|
||||||
|
|
||||||
#include "core/frame.h"
|
#include "core/frame.h"
|
||||||
#include "core/window-private.h"
|
#include "core/window-private.h"
|
||||||
@ -61,6 +62,7 @@ static void meta_ui_frame_update_prelit_control (MetaUIFrame *frame,
|
|||||||
|
|
||||||
static void meta_frames_font_changed (MetaFrames *frames);
|
static void meta_frames_font_changed (MetaFrames *frames);
|
||||||
static void meta_frames_button_layout_changed (MetaFrames *frames);
|
static void meta_frames_button_layout_changed (MetaFrames *frames);
|
||||||
|
static void meta_frames_reattach_all_styles (MetaFrames *frames);
|
||||||
|
|
||||||
|
|
||||||
static GdkRectangle* control_rect (MetaFrameControl control,
|
static GdkRectangle* control_rect (MetaFrameControl control,
|
||||||
@ -207,6 +209,12 @@ update_style_contexts (MetaFrames *frames)
|
|||||||
static void
|
static void
|
||||||
meta_frames_init (MetaFrames *frames)
|
meta_frames_init (MetaFrames *frames)
|
||||||
{
|
{
|
||||||
|
frames->interface_settings = g_settings_new ("org.gnome.desktop.interface");
|
||||||
|
g_signal_connect_swapped (frames->interface_settings,
|
||||||
|
"changed::color-scheme",
|
||||||
|
G_CALLBACK (meta_frames_reattach_all_styles),
|
||||||
|
frames);
|
||||||
|
|
||||||
frames->text_heights = g_hash_table_new (NULL, NULL);
|
frames->text_heights = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
|
frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
|
||||||
@ -260,6 +268,8 @@ meta_frames_destroy (GtkWidget *object)
|
|||||||
frames->style_variants = NULL;
|
frames->style_variants = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_object (&frames->interface_settings);
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (meta_frames_parent_class)->destroy (object);
|
GTK_WIDGET_CLASS (meta_frames_parent_class)->destroy (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +341,13 @@ reattach_style_func (gpointer key, gpointer value, gpointer data)
|
|||||||
meta_ui_frame_attach_style (frame);
|
meta_ui_frame_attach_style (frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_frames_reattach_all_styles (MetaFrames *frames)
|
||||||
|
{
|
||||||
|
g_hash_table_foreach (frames->frames, reattach_style_func, NULL);
|
||||||
|
meta_display_queue_retheme_all_windows (meta_get_display ());
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_frames_style_updated (GtkWidget *widget)
|
meta_frames_style_updated (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@ -342,9 +359,7 @@ meta_frames_style_updated (GtkWidget *widget)
|
|||||||
|
|
||||||
update_style_contexts (frames);
|
update_style_contexts (frames);
|
||||||
|
|
||||||
g_hash_table_foreach (frames->frames, reattach_style_func, NULL);
|
meta_frames_reattach_all_styles (frames);
|
||||||
|
|
||||||
meta_display_queue_retheme_all_windows (meta_get_display ());
|
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (meta_frames_parent_class)->style_updated (widget);
|
GTK_WIDGET_CLASS (meta_frames_parent_class)->style_updated (widget);
|
||||||
}
|
}
|
||||||
@ -478,6 +493,17 @@ get_global_theme_variant (MetaFrames *frames)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_color_scheme_variant (MetaFrames *frames)
|
||||||
|
{
|
||||||
|
int color_scheme = g_settings_get_enum (frames->interface_settings, "color-scheme");
|
||||||
|
|
||||||
|
if (color_scheme == G_DESKTOP_COLOR_SCHEME_PREFER_DARK)
|
||||||
|
return "dark";
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* In order to use a style with a window it has to be attached to that
|
/* In order to use a style with a window it has to be attached to that
|
||||||
* window. Actually, the colormaps just have to match, but since GTK+
|
* window. Actually, the colormaps just have to match, but since GTK+
|
||||||
* already takes care of making sure that its cheap to attach a style
|
* already takes care of making sure that its cheap to attach a style
|
||||||
@ -496,6 +522,8 @@ meta_ui_frame_attach_style (MetaUIFrame *frame)
|
|||||||
variant = frame->meta_window->gtk_theme_variant;
|
variant = frame->meta_window->gtk_theme_variant;
|
||||||
if (variant == NULL)
|
if (variant == NULL)
|
||||||
variant = get_global_theme_variant (frame->frames);
|
variant = get_global_theme_variant (frame->frames);
|
||||||
|
if (variant == NULL)
|
||||||
|
variant = get_color_scheme_variant (frame->frames);
|
||||||
|
|
||||||
if (variant == NULL || *variant == '\0')
|
if (variant == NULL || *variant == '\0')
|
||||||
frame->style_info = meta_style_info_ref (frames->normal_style);
|
frame->style_info = meta_style_info_ref (frames->normal_style);
|
||||||
|
@ -98,6 +98,8 @@ struct _MetaFrames
|
|||||||
MetaStyleInfo *normal_style;
|
MetaStyleInfo *normal_style;
|
||||||
GHashTable *style_variants;
|
GHashTable *style_variants;
|
||||||
|
|
||||||
|
GSettings *interface_settings;
|
||||||
|
|
||||||
MetaGrabOp current_grab_op;
|
MetaGrabOp current_grab_op;
|
||||||
MetaUIFrame *grab_frame;
|
MetaUIFrame *grab_frame;
|
||||||
guint grab_button;
|
guint grab_button;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user