From 2eb252199c8c0118a1ff51e49823ceceef637e1c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 25 Nov 2022 07:59:35 -0500 Subject: [PATCH] text: Prevent unexpected notify::direction emissions 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 6c13cd1907..6f7d23b7f5 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -3258,8 +3258,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);