diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-15 15:10:06 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-16 11:17:48 -0500 |
commit | fcceac6d118354ac3e73cd80c4dab8d026e49721 (patch) | |
tree | ba812fcdebf2e94c9cdce8c2b62fd693c03121c3 /gtk/gtkcssnode.c | |
parent | e8eb1df29f15361697d7f6062d0466f61d072f2e (diff) | |
download | gtk+-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.c | 14 |
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]); } } |