[gtk/gtk-3-24: 5/9] gtkentry: Avoid early IM reset on updates
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24: 5/9] gtkentry: Avoid early IM reset on updates
- Date: Thu, 6 Oct 2022 10:57:36 +0000 (UTC)
commit fa6aca2925eadb341b7d03d0cee22d452cb64951
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Sep 6 21:43:14 2022 +0200
gtkentry: 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.
gtk/gtkentry.c | 4 ----
gtk/gtktextview.c | 9 +--------
2 files changed, 1 insertion(+), 12 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index d26f4de176..f8050df565 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -6155,10 +6155,8 @@ gtk_entry_enter_text (GtkEntry *entry,
GtkEntryPrivate *priv = entry->priv;
GtkEditable *editable = GTK_EDITABLE (entry);
gint tmp_pos;
- gboolean old_need_im_reset;
guint text_length;
- old_need_im_reset = priv->need_im_reset;
priv->need_im_reset = FALSE;
if (gtk_editable_get_selection_bounds (editable, NULL, NULL))
@@ -6176,8 +6174,6 @@ gtk_entry_enter_text (GtkEntry *entry,
tmp_pos = priv->current_pos;
gtk_editable_insert_text (editable, str, strlen (str), &tmp_pos);
gtk_editable_set_position (editable, tmp_pos);
-
- priv->need_im_reset = old_need_im_reset;
}
/* All changes to priv->current_pos and priv->selection_bound
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 148f744381..57dd199e2e 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5491,9 +5491,6 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
{
GtkTextView *text_view;
GtkTextViewPrivate *priv;
- GtkTextMark *insert;
- GtkTextIter iter;
- gboolean can_insert;
gboolean retval = FALSE;
text_view = GTK_TEXT_VIEW (widget);
@@ -5507,14 +5504,9 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
/* Make sure input method knows where it is */
flush_update_im_spot_location (text_view);
- 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);
if (gtk_im_context_filter_keypress (priv->im_context, event))
{
priv->need_im_reset = TRUE;
- if (can_insert)
- gtk_text_view_reset_im_context (text_view);
retval = TRUE;
}
/* Binding set */
@@ -9109,6 +9101,7 @@ gtk_text_view_commit_handler (GtkIMContext *context,
GtkTextView *text_view)
{
gtk_text_view_commit_text (text_view, str);
+ gtk_im_context_reset (context);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]