text: Prevent unexpected notify::direction emissions
authorMatthias Clasen <mclasen@redhat.com>
Fri, 25 Nov 2022 12:59:35 +0000 (07:59 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 14 Dec 2022 16:28:19 +0000 (11:28 -0500)
Calling gdk_device_get_direction can trigger a
notify::direction emissions, since the X11 backend
determines the direction on demand. Prevent that by
forcing the direction to be determined ahead of time.

Fixes: #5311
gtk/gtktext.c

index 8631dbba71274caab2356b33408a51907bde85ca..72daa5d444495446d6192e2aa80109094b43e06d 100644 (file)
@@ -3234,8 +3234,12 @@ gtk_text_focus_changed (GtkEventControllerFocus *controller,
   if (gtk_event_controller_focus_is_focus (controller))
     {
       if (keyboard)
-        g_signal_connect (keyboard, "notify::direction",
-                          G_CALLBACK (direction_changed), self);
+        {
+          /* Work around unexpected notify::direction emissions */
+          gdk_device_get_direction (keyboard);
+          g_signal_connect (keyboard, "notify::direction",
+                            G_CALLBACK (direction_changed), self);
+        }
 
       gtk_text_im_set_focus_in (self);
       gtk_text_reset_blink_time (self);