[gtk/gtk-4-6: 5/15] gtktext: Also reset IM context after IM surrounding text deletion




commit 735f803c2faf5f1fa4ffacd7a059acaff4e12dec
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Sep 6 21:53:25 2022 +0200

    gtktext: Also reset IM context after IM surrounding text deletion
    
    When the IM commands the GtkText to delete text, the cursor position
    would change, and so would the surrounding text. Reset the IM context
    so that these updates are properly picked up by the IM.
    
    Fixes backspace key behavior in the GNOME Shell OSK, since that relies
    on the surrounding text being properly updated for the next iteration.

 gtk/gtktext.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index e4e4c90917..d96482ec1c 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -4333,9 +4333,12 @@ gtk_text_delete_surrounding_cb (GtkIMContext *context,
   GtkTextPrivate *priv = gtk_text_get_instance_private (self);
 
   if (priv->editable)
-    gtk_editable_delete_text (GTK_EDITABLE (self),
-                              priv->current_pos + offset,
-                              priv->current_pos + offset + n_chars);
+    {
+      gtk_editable_delete_text (GTK_EDITABLE (self),
+                                priv->current_pos + offset,
+                                priv->current_pos + offset + n_chars);
+      gtk_im_context_reset (context);
+    }
 
   return TRUE;
 }


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