[gnome-shell] st/entry: Invalidate text shadow on style changes to ClutterText



commit 898334f31d62cc7e035c860cb977ba8e6adccb35
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Fri Mar 5 12:17:07 2021 +0100

    st/entry: Invalidate text shadow on style changes to ClutterText
    
    We update a few properties of ClutterText when the CSS changes via
    _st_set_text_from_style() (which we call when receiving the
    style-changed signal).
    
    Right now we simply invalidate the text shadow every time we receive the
    style-changed signal, but we're going to change that with the next
    commits. To ensure the shadow still gets invalidated on CSS changed that
    might affect the shadow, listen to a bunch of property changes that will
    get notified when any property that affects the shadow changes.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1744>

 src/st/st-entry.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index d50c2548bd..e2e985df67 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -562,6 +562,16 @@ clutter_text_changed_cb (GObject    *object,
   g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]);
 }
 
+static void
+invalidate_shadow_pipeline (GObject    *object,
+                            GParamSpec *pspec,
+                            StEntry    *entry)
+{
+  StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
+
+  g_clear_pointer (&priv->text_shadow_material, cogl_object_unref);
+}
+
 static void
 st_entry_clipboard_callback (StClipboard *clipboard,
                              const gchar *text,
@@ -1058,6 +1068,20 @@ st_entry_init (StEntry *entry)
   g_signal_connect (priv->entry, "notify::text",
                     G_CALLBACK (clutter_text_changed_cb), entry);
 
+  /* These properties might get set from CSS using _st_set_text_from_style */
+  g_signal_connect (priv->entry, "notify::font-description",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::attributes",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::justify",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+  g_signal_connect (priv->entry, "notify::line-alignment",
+                    G_CALLBACK (invalidate_shadow_pipeline), entry);
+
+
   priv->spacing = 6.0f;
 
   priv->text_shadow_material = NULL;


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