summaryrefslogtreecommitdiff
path: root/gtk/gtkcssnode.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-01-15 15:10:06 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-01-16 11:17:48 -0500
commitfcceac6d118354ac3e73cd80c4dab8d026e49721 (patch)
treeba812fcdebf2e94c9cdce8c2b62fd693c03121c3 /gtk/gtkcssnode.c
parente8eb1df29f15361697d7f6062d0466f61d072f2e (diff)
downloadgtk+-fcceac6d118354ac3e73cd80c4dab8d026e49721.tar.gz
css: Track hover state changes separately
The idea is that this reduce the amount of frequently changing state that css nodes are sensitive to. This is going to reduce the amount of style recomputation.
Diffstat (limited to 'gtk/gtkcssnode.c')
-rw-r--r--gtk/gtkcssnode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 0cce324e05..cdc72d1881 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -1138,9 +1138,21 @@ void
gtk_css_node_set_state (GtkCssNode *cssnode,
GtkStateFlags state_flags)
{
+ GtkStateFlags old_state;
+
+ old_state = gtk_css_node_declaration_get_state (cssnode->decl);
+
if (gtk_css_node_declaration_set_state (&cssnode->decl, state_flags))
{
- gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_STATE);
+ GtkStateFlags states = old_state ^ state_flags;
+ GtkCssChange change = 0;
+
+ if (states & GTK_STATE_FLAG_PRELIGHT)
+ change |= GTK_CSS_CHANGE_HOVER;
+ if (states & ~GTK_STATE_FLAG_PRELIGHT)
+ change |= GTK_CSS_CHANGE_STATE;
+
+ gtk_css_node_invalidate (cssnode, change);
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_STATE]);
}
}