[gnome-shell/gnome-3-36] st/theme-context: Also remove theme nodes on stylesheet changes



commit e57a4e09377e0cab301700398ff1a7131bd9803b
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sat Apr 25 11:17:13 2020 +0000

    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 4dfa39457e4ed16e7ae5168cf313dd9513b7fb03)

 src/st/st-theme-context.c      | 23 ++++-------------------
 src/st/st-theme-node-private.h |  1 -
 src/st/st-theme-node.c         |  7 -------
 3 files changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/src/st/st-theme-context.c b/src/st/st-theme-context.c
index 55e856f265..f10737b803 100644
--- a/src/st/st-theme-context.c
+++ b/src/st/st-theme-context.c
@@ -290,22 +290,6 @@ on_icon_theme_changed (StTextureCache *cache,
   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:
  * @stage: a #ClutterStage
@@ -358,9 +342,10 @@ st_theme_context_set_theme (StThemeContext          *context,
       if (context->theme)
         {
           context->stylesheets_changed_id =
-            g_signal_connect (context->theme, "custom-stylesheets-changed",
-                              G_CALLBACK (on_custom_stylesheets_changed),
-                              context);
+            g_signal_connect_swapped (context->theme,
+                                      "custom-stylesheets-changed",
+                                      G_CALLBACK (st_theme_context_changed),
+                                      context);
         }
 
       st_theme_context_changed (context);
diff --git a/src/st/st-theme-node-private.h b/src/st/st-theme-node-private.h
index dedb3cc8f9..7533482616 100644
--- a/src/st/st-theme-node-private.h
+++ b/src/st/st-theme-node-private.h
@@ -125,7 +125,6 @@ void _st_theme_node_ensure_background (StThemeNode *node);
 void _st_theme_node_ensure_geometry (StThemeNode *node);
 void _st_theme_node_apply_margins (StThemeNode *node,
                                    ClutterActor *actor);
-void _st_theme_node_reset_for_stylesheet_change (StThemeNode *node);
 
 G_END_DECLS
 
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 85e5dbe418..ca9675895b 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -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
 st_theme_node_dispose (GObject *gobject)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]