[gtk/wip/carlosg/im-fixes-4-6: 2/3] gtktextview: Shuffle the places doing IM reset
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/im-fixes-4-6: 2/3] gtktextview: Shuffle the places doing IM reset
- Date: Thu, 18 Aug 2022 18:36:27 +0000 (UTC)
commit 34693b0d9fddfa4df082dbee72d1cf890c86d295
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Aug 18 00:58:14 2022 +0200
gtktextview: 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.
Also, fix a bug during GtkEventControllerKey::im-update where the condition
on cursor position editability to reset the IM context was inverted.
(cherry-picked from commit 52ac71b9727b9a63773865309a970c4d97c0a75d)
gtk/gtktextview.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 5f8bb14ffb..f7b1687581 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5525,7 +5525,7 @@ gtk_text_view_key_controller_im_update (GtkEventControllerKey *controller,
can_insert = gtk_text_iter_can_insert (&iter, priv->editable);
priv->need_im_reset = TRUE;
- if (!can_insert)
+ if (can_insert)
gtk_text_view_reset_im_context (text_view);
}
@@ -6358,8 +6358,6 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
return;
}
- gtk_text_view_reset_im_context (text_view);
-
if (step == GTK_MOVEMENT_PAGES)
{
if (!gtk_text_view_scroll_pages (text_view, count, extend_selection))
@@ -6543,6 +6541,9 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
gtk_text_view_check_cursor_blink (text_view);
gtk_text_view_pend_cursor_blink (text_view);
+
+ priv->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
}
static void
@@ -6833,14 +6834,16 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
priv = text_view->priv;
- gtk_text_view_reset_im_context (text_view);
-
if (type == GTK_DELETE_CHARS)
{
/* Char delete deletes the selection, if one exists */
if (gtk_text_buffer_delete_selection (get_buffer (text_view), TRUE,
priv->editable))
- return;
+ {
+ priv->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
+ return;
+ }
}
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
@@ -6967,6 +6970,9 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
{
gtk_widget_error_bell (GTK_WIDGET (text_view));
}
+
+ priv->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
}
static void
@@ -6977,12 +6983,14 @@ gtk_text_view_backspace (GtkTextView *text_view)
priv = text_view->priv;
- gtk_text_view_reset_im_context (text_view);
-
/* Backspace deletes the selection, if one exists */
if (gtk_text_buffer_delete_selection (get_buffer (text_view), TRUE,
priv->editable))
- return;
+ {
+ priv->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
+ return;
+ }
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&insert,
@@ -6995,6 +7003,9 @@ gtk_text_view_backspace (GtkTextView *text_view)
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_insert (get_buffer (text_view)));
+
+ priv->need_im_reset = TRUE;
+ gtk_text_view_reset_im_context (text_view);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]