[gtk/wip/carlosg/im-fixes: 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: 2/3] gtktextview: Shuffle the places doing IM reset
- Date: Thu, 18 Aug 2022 17:24:37 +0000 (UTC)
commit 52ac71b9727b9a63773865309a970c4d97c0a75d
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.
gtk/gtktextview.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index bb053696e2..bfd3616530 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5533,7 +5533,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);
}
@@ -6366,8 +6366,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))
@@ -6551,6 +6549,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
@@ -6841,14 +6842,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,
@@ -6975,6 +6978,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
@@ -6985,12 +6991,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,
@@ -7003,6 +7011,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]