[mutter] clutter/text: Emit cursor-changed right after setting cursor position



commit ef1f65a01337c2da1f3c4d9aea71477e04f5af98
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Fri Mar 5 16:53:15 2021 +0100

    clutter/text: Emit cursor-changed right after setting cursor position
    
    ClutterText has a bit of a mess around its signalling of changes to the
    cursor position: There's the position (deprecated) and cursor-position
    property, and  there's the cursor-changed and cursor-event (deprecated)
    signal. The two properties are supposed to be notified when the cursor
    position changes, and the two signals are notified when the cursor
    position or size changes.
    
    Now the properties notifications and the signals get fired in two very
    different places: The two properties are notified in
    clutter_text_set_cursor_position(), while the signals are fired during
    the paint cycle when we figured out the final cursor position. The
    latter is a pretty bad idea, nobody expects such a signal to be fired
    during painting, and also changes to the text that are done in the
    signal handler will only be applied on the next paint.
    
    Now StEntry listens to cursor position changes via cursor-changed and
    invalidates its text shadow, but since the signal is only notified
    during the paint, the old text shadow will still get applied. To fix
    this, also emit the cursor-changed signal when we notify the
    cursor-position property.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1757>

 clutter/clutter/clutter-text.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 5ecc1807a7..45c7eac56b 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -1416,6 +1416,7 @@ clutter_text_delete_selection (ClutterText *self)
       /* XXX:2.0 - remove */
       g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_POSITION]);
       g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CURSOR_POSITION]);
+      g_signal_emit (self, text_signals[CURSOR_CHANGED], 0);
     }
 
   if (priv->selection_bound != old_selection)
@@ -6259,6 +6260,7 @@ clutter_text_set_cursor_position (ClutterText *self,
   /* XXX:2.0 - remove */
   g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_POSITION]);
   g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_CURSOR_POSITION]);
+  g_signal_emit (self, text_signals[CURSOR_CHANGED], 0);
 }
 
 /**


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