summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-08-18 00:55:30 +0200
committerCarlos Garnacho <carlosg@gnome.org>2022-08-18 00:55:30 +0200
commit9e29739e6676bdb313aa19ce54c9da6c39cd4778 (patch)
tree24e0278764323ff4147a37f2f6cef21418fa2380 /gtk
parent82395e73ad035fc5350261e93174b847125a87cc (diff)
downloadgtk+-9e29739e6676bdb313aa19ce54c9da6c39cd4778.tar.gz
gtktext: Shuffle the places doing IM reset
During text widget manipulation (inserting or deleting text via keyboard) the IM context is reset somewhat early, before the actual change took place. This makes IM lag behind in terms of surrounding text and cursor position. Shuffle these IM reset calls so that they happen after the changes, and ensure that the IM is actually reset, since that is currently toggled on a pretty narrow set of circumstances.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktext.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 3a390fcc11..70b100fa55 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -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_text_schedule_im_reset), self);
+ G_CALLBACK (gtk_im_context_reset), priv->im_context);
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);
@@ -3773,8 +3773,6 @@ gtk_text_move_cursor (GtkText *self,
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
int new_pos = priv->current_pos;
- gtk_text_reset_im_context (self);
-
if (priv->current_pos != priv->selection_bound && !extend_selection)
{
/* If we have a current selection and aren't extending it, move to the
@@ -3901,6 +3899,9 @@ gtk_text_move_cursor (GtkText *self,
gtk_text_set_selection_bounds (self, new_pos, new_pos);
gtk_text_pend_cursor_blink (self);
+
+ priv->need_im_reset = TRUE;
+ gtk_text_reset_im_context (self);
}
static void
@@ -3928,8 +3929,6 @@ gtk_text_delete_from_cursor (GtkText *self,
int end_pos = priv->current_pos;
int old_n_bytes = gtk_entry_buffer_get_bytes (get_buffer (self));
- gtk_text_reset_im_context (self);
-
if (!priv->editable)
{
gtk_widget_error_bell (GTK_WIDGET (self));
@@ -3939,6 +3938,8 @@ gtk_text_delete_from_cursor (GtkText *self,
if (priv->selection_bound != priv->current_pos)
{
gtk_text_delete_selection (self);
+ gtk_text_schedule_im_reset (self);
+ gtk_text_reset_im_context (self);
return;
}
@@ -4003,6 +4004,11 @@ gtk_text_delete_from_cursor (GtkText *self,
if (gtk_entry_buffer_get_bytes (get_buffer (self)) == old_n_bytes)
gtk_widget_error_bell (GTK_WIDGET (self));
+ else
+ {
+ gtk_text_schedule_im_reset (self);
+ gtk_text_reset_im_context (self);
+ }
gtk_text_pend_cursor_blink (self);
}
@@ -4013,8 +4019,6 @@ gtk_text_backspace (GtkText *self)
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
int prev_pos;
- gtk_text_reset_im_context (self);
-
if (!priv->editable)
{
gtk_widget_error_bell (GTK_WIDGET (self));
@@ -4024,6 +4028,8 @@ gtk_text_backspace (GtkText *self)
if (priv->selection_bound != priv->current_pos)
{
gtk_text_delete_selection (self);
+ gtk_text_schedule_im_reset (self);
+ gtk_text_reset_im_context (self);
return;
}
@@ -4068,6 +4074,9 @@ gtk_text_backspace (GtkText *self)
{
gtk_editable_delete_text (GTK_EDITABLE (self), prev_pos, priv->current_pos);
}
+
+ gtk_text_schedule_im_reset (self);
+ gtk_text_reset_im_context (self);
}
else
{