gtktext: Avoid early IM reset on updates
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 6 Sep 2022 19:38:35 +0000 (21:38 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 6 Sep 2022 20:17:40 +0000 (22:17 +0200)
Resetting the IM on IM updates is too eager and indeed the simple
IM context doesn't like that this happens in the middle of dead
key handling.

We however want to reset the IM after actual text buffer changes
(say, a committed string) moved the cursor position, altered the
surrounding text, etc. So that the IM implementation does know to
update its state.

Fixes: 9e29739e66 ("gtktext: Shuffle the places doing IM reset")
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5133
gtk/gtktext.c

index b95d6d8c516d23eaf3ac0008b3f3b3e125b5de50..0e10b9e9474abdb759934855ce2b36d89e8bcd53 100644 (file)
@@ -1910,7 +1910,7 @@ gtk_text_init (GtkText *self)
   g_signal_connect (priv->key_controller, "key-pressed",
                     G_CALLBACK (gtk_text_key_controller_key_pressed), self);
   g_signal_connect_swapped (priv->key_controller, "im-update",
-                            G_CALLBACK (gtk_im_context_reset), priv->im_context);
+                            G_CALLBACK (gtk_text_schedule_im_reset), self);
   gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (priv->key_controller),
                                            priv->im_context);
   gtk_widget_add_controller (GTK_WIDGET (self), priv->key_controller);
@@ -4241,6 +4241,7 @@ gtk_text_commit_cb (GtkIMContext *context,
     {
       gtk_text_enter_text (self, str);
       gtk_text_obscure_mouse_cursor (self);
+      gtk_im_context_reset (context);
     }
 }