[gtk/wip/otte/css: 9/17] css: Introduce GTK_CSS_CHANGE_ROOT



commit 78b6679c431149f0efd2fcea36201a7cac81e152
Author: Benjamin Otte <otte redhat com>
Date:   Sun Feb 9 22:08:25 2020 +0100

    css: Introduce GTK_CSS_CHANGE_ROOT
    
    This is meant for any change triggered by the root, such as default
    values, icontheme or scale factor.
    
    So far it is only triggered by reparenting a CSS node and it's
    managed the same way as GTK_CSS_CHANGE_SOURCE.

 gtk/gtkcssnode.c         | 6 ++++--
 gtk/gtkcsstypes.c        | 5 +++--
 gtk/gtkcsstypesprivate.h | 8 +++++---
 3 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 52b88909bc..4c37da7d04 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -89,7 +89,7 @@
  * if we need to change things. */
 #define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_ID | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | \
                                 GTK_CSS_CHANGE_PARENT_ID | GTK_CSS_CHANGE_PARENT_NAME | 
GTK_CSS_CHANGE_PARENT_CLASS | \
-                                GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
+                                GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_ROOT | GTK_CSS_CHANGE_PARENT_STYLE)
 
 /* When these change, we need to recompute the change flags for the new style
  * since they may have changed.
@@ -754,7 +754,9 @@ gtk_css_node_reposition (GtkCssNode *node,
 
       if (gtk_css_node_get_style_provider_or_null (node) == NULL)
         gtk_css_node_invalidate_style_provider (node);
-      gtk_css_node_invalidate (node, GTK_CSS_CHANGE_TIMESTAMP | GTK_CSS_CHANGE_ANIMATIONS);
+      gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ROOT
+                                   | GTK_CSS_CHANGE_TIMESTAMP
+                                   | GTK_CSS_CHANGE_ANIMATIONS);
 
       if (new_parent)
         {
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c
index 5cead98c03..b43ed074d3 100644
--- a/gtk/gtkcsstypes.c
+++ b/gtk/gtkcsstypes.c
@@ -38,7 +38,7 @@ _gtk_css_change_for_sibling (GtkCssChange match)
                     | GTK_CSS_CHANGE_SELECTED \
                     | GTK_CSS_CHANGE_BACKDROP)
 
-#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE) \
+#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_ROOT|GTK_CSS_CHANGE_PARENT_STYLE) \
                     | GTK_CSS_CHANGE_NTH_CHILD \
                     | GTK_CSS_CHANGE_NTH_LAST_CHILD)
 
@@ -76,7 +76,7 @@ _gtk_css_change_for_child (GtkCssChange match)
                     | GTK_CSS_CHANGE_SIBLING_BACKDROP \
                     | GTK_CSS_CHANGE_SIBLING_SELECTED)
 
-#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE))
+#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_ROOT|GTK_CSS_CHANGE_PARENT_STYLE))
 
   return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_PARENT_SHIFT);
 
@@ -145,6 +145,7 @@ gtk_css_change_print (GtkCssChange  change,
     { GTK_CSS_CHANGE_PARENT_SIBLING_SELECTED, "parent-sibling-selected" },
 
     { GTK_CSS_CHANGE_SOURCE, "source" },
+    { GTK_CSS_CHANGE_ROOT, "root" },
     { GTK_CSS_CHANGE_PARENT_STYLE, "parent-style" },
     { GTK_CSS_CHANGE_TIMESTAMP, "timestamp" },
     { GTK_CSS_CHANGE_ANIMATIONS, "animations" },
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 1e18fac297..105da86113 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -90,9 +90,10 @@ typedef struct _GtkCssStaticStyle GtkCssStaticStyle;
 
 /* add more */
 #define GTK_CSS_CHANGE_SOURCE                         (1ULL << 48)
-#define GTK_CSS_CHANGE_PARENT_STYLE                   (1ULL << 49)
-#define GTK_CSS_CHANGE_TIMESTAMP                      (1ULL << 50)
-#define GTK_CSS_CHANGE_ANIMATIONS                     (1ULL << 51)
+#define GTK_CSS_CHANGE_ROOT                           (1ULL << 49)
+#define GTK_CSS_CHANGE_PARENT_STYLE                   (1ULL << 50)
+#define GTK_CSS_CHANGE_TIMESTAMP                      (1ULL << 51)
+#define GTK_CSS_CHANGE_ANIMATIONS                     (1ULL << 52)
 
 #define GTK_CSS_CHANGE_RESERVED_BIT                   (1ULL << 62)
 
@@ -122,6 +123,7 @@ typedef guint64 GtkCssChange;
                             GTK_CSS_CHANGE_ANY_PARENT         | \
                             GTK_CSS_CHANGE_ANY_PARENT_SIBLING | \
                             GTK_CSS_CHANGE_SOURCE             | \
+                            GTK_CSS_CHANGE_ROOT               | \
                             GTK_CSS_CHANGE_PARENT_STYLE       | \
                             GTK_CSS_CHANGE_TIMESTAMP          | \
                             GTK_CSS_CHANGE_ANIMATIONS)


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