st/theme-context: Also remove theme nodes on stylesheet changes

StThemeNodes are built around the assumption that they're "immutable",
that means they are created once with certain parameters (that resolve
to certain css properties) and then replaced with new ones in case those
parameters changed.

Changes to the internal information stored by theme nodes (i.e. the css
properties, font names or the cached scale-factor) are not all handled
the same though: For changes to the font or the scale-factor we remove
all theme nodes from the cache and let the widgets which are on stage
generate new theme nodes. For changes to the css properties/the
stylesheet, we invalidate the properties of all theme nodes but keep
them in the cache using `_st_theme_node_reset_for_stylesheet_change()`.

So be a bit more consistent and handle changes to the css-properties/the
stylesheet stored by StThemeNodes the same way as changes to the font or
scale-factor.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1218


(cherry picked from commit 4dfa39457e)
This commit is contained in:
Jonas Dreßler 2020-04-25 11:17:13 +00:00 committed by Florian Müllner
parent 443d615edf
commit e57a4e0937
3 changed files with 4 additions and 27 deletions

View File

@ -290,22 +290,6 @@ on_icon_theme_changed (StTextureCache *cache,
g_source_set_name_by_id (id, "[gnome-shell] changed_idle"); g_source_set_name_by_id (id, "[gnome-shell] changed_idle");
} }
static void
on_custom_stylesheets_changed (StTheme *theme,
StThemeContext *context)
{
GHashTableIter iter;
StThemeNode *node;
if (context->root_node)
_st_theme_node_reset_for_stylesheet_change (context->root_node);
g_hash_table_iter_init (&iter, context->nodes);
while (g_hash_table_iter_next (&iter, (gpointer *) &node, NULL))
_st_theme_node_reset_for_stylesheet_change (node);
}
/** /**
* st_theme_context_get_for_stage: * st_theme_context_get_for_stage:
* @stage: a #ClutterStage * @stage: a #ClutterStage
@ -358,8 +342,9 @@ st_theme_context_set_theme (StThemeContext *context,
if (context->theme) if (context->theme)
{ {
context->stylesheets_changed_id = context->stylesheets_changed_id =
g_signal_connect (context->theme, "custom-stylesheets-changed", g_signal_connect_swapped (context->theme,
G_CALLBACK (on_custom_stylesheets_changed), "custom-stylesheets-changed",
G_CALLBACK (st_theme_context_changed),
context); context);
} }

View File

@ -125,7 +125,6 @@ void _st_theme_node_ensure_background (StThemeNode *node);
void _st_theme_node_ensure_geometry (StThemeNode *node); void _st_theme_node_ensure_geometry (StThemeNode *node);
void _st_theme_node_apply_margins (StThemeNode *node, void _st_theme_node_apply_margins (StThemeNode *node,
ClutterActor *actor); ClutterActor *actor);
void _st_theme_node_reset_for_stylesheet_change (StThemeNode *node);
G_END_DECLS G_END_DECLS

View File

@ -77,13 +77,6 @@ maybe_free_properties (StThemeNode *node)
} }
} }
void
_st_theme_node_reset_for_stylesheet_change (StThemeNode *node)
{
maybe_free_properties (node);
node->properties_computed = FALSE;
}
static void static void
st_theme_node_dispose (GObject *gobject) st_theme_node_dispose (GObject *gobject)
{ {