gtktext: Avoid early IM reset on updates

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.

Since there is going to be an actual IM reset anyways, it does
no longer make sense to try to preserve the old priv->need_im_reset
status during commit handling.

Fixes: 52ac71b972 ("gtktextview: Shuffle the places doing IM reset")
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5133
This commit is contained in:
Carlos Garnacho 2022-09-06 21:43:14 +02:00
parent 085374198f
commit 41f26975a9
2 changed files with 1 additions and 13 deletions

View File

@ -4315,10 +4315,8 @@ gtk_text_enter_text (GtkText *self,
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
int tmp_pos;
gboolean old_need_im_reset;
guint text_length;
old_need_im_reset = priv->need_im_reset;
priv->need_im_reset = FALSE;
if (priv->selection_bound != priv->current_pos)
@ -4336,8 +4334,6 @@ gtk_text_enter_text (GtkText *self,
tmp_pos = priv->current_pos;
gtk_editable_insert_text (GTK_EDITABLE (self), str, strlen (str), &tmp_pos);
gtk_text_set_selection_bounds (self, tmp_pos, tmp_pos);
priv->need_im_reset = old_need_im_reset;
}
/* All changes to priv->current_pos and priv->selection_bound

View File

@ -5524,17 +5524,8 @@ gtk_text_view_key_controller_im_update (GtkEventControllerKey *controller,
GtkTextView *text_view)
{
GtkTextViewPrivate *priv = text_view->priv;
GtkTextMark *insert;
GtkTextIter iter;
gboolean can_insert;
insert = gtk_text_buffer_get_insert (get_buffer (text_view));
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, insert);
can_insert = gtk_text_iter_can_insert (&iter, priv->editable);
priv->need_im_reset = TRUE;
if (can_insert)
gtk_text_view_reset_im_context (text_view);
}
static gboolean
@ -8494,6 +8485,7 @@ gtk_text_view_commit_handler (GtkIMContext *context,
gtk_text_view_commit_text (text_view, str);
gtk_text_view_reset_blink_time (text_view);
gtk_text_view_pend_cursor_blink (text_view);
gtk_im_context_reset (context);
}
static void