st/theme-context: Keep a pointer to ClutterBackend

Allows avoiding the usage of the global one and would also be used in
the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3528>
This commit is contained in:
Bilal Elmoussaoui 2025-01-08 14:57:18 +01:00 committed by Marge Bot
parent f5b58cf102
commit eaee51ff16

View File

@ -43,6 +43,8 @@
struct _StThemeContext { struct _StThemeContext {
GObject parent; GObject parent;
ClutterBackend *clutter_backend;
PangoFontDescription *font; PangoFontDescription *font;
CoglColor accent_color; CoglColor accent_color;
CoglColor accent_fg_color; CoglColor accent_fg_color;
@ -124,7 +126,7 @@ st_theme_context_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (), g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
(gpointer) on_icon_theme_changed, (gpointer) on_icon_theme_changed,
context); context);
g_signal_handlers_disconnect_by_func (clutter_get_default_backend (), g_signal_handlers_disconnect_by_func (context->clutter_backend,
(gpointer) st_theme_context_changed, (gpointer) st_theme_context_changed,
context); context);
@ -196,10 +198,6 @@ st_theme_context_init (StThemeContext *context)
"icon-theme-changed", "icon-theme-changed",
G_CALLBACK (on_icon_theme_changed), G_CALLBACK (on_icon_theme_changed),
context); context);
g_signal_connect_swapped (clutter_get_default_backend (),
"resolution-changed",
G_CALLBACK (st_theme_context_changed),
context);
context->nodes = g_hash_table_new_full ((GHashFunc) st_theme_node_hash, context->nodes = g_hash_table_new_full ((GHashFunc) st_theme_node_hash,
(GEqualFunc) st_theme_node_equal, (GEqualFunc) st_theme_node_equal,
@ -379,6 +377,7 @@ StThemeContext *
st_theme_context_get_for_stage (ClutterStage *stage) st_theme_context_get_for_stage (ClutterStage *stage)
{ {
StThemeContext *context; StThemeContext *context;
ClutterContext *clutter_context;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL); g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
@ -386,11 +385,18 @@ st_theme_context_get_for_stage (ClutterStage *stage)
if (context) if (context)
return context; return context;
clutter_context = clutter_actor_get_context (CLUTTER_ACTOR (stage));
context = g_object_new (ST_TYPE_THEME_CONTEXT, NULL); context = g_object_new (ST_TYPE_THEME_CONTEXT, NULL);
context->clutter_backend = clutter_context_get_backend (clutter_context);
g_object_set_data (G_OBJECT (stage), "st-theme-context", context); g_object_set_data (G_OBJECT (stage), "st-theme-context", context);
g_signal_connect (stage, "destroy", g_signal_connect (stage, "destroy",
G_CALLBACK (on_stage_destroy), NULL); G_CALLBACK (on_stage_destroy), NULL);
g_signal_connect_swapped (context->clutter_backend,
"resolution-changed",
G_CALLBACK (st_theme_context_changed),
context);
return context; return context;
} }