summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-18 15:44:21 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-18 15:44:21 -0500
commit1282cac99d57262c61ace18fa8318ade49baa577 (patch)
treea151fbfda1ea41da6c1409c1190cde7d98b6e7d8
parent784b23696407211980a0e83de6587480ef31c065 (diff)
downloadgtk+-unintrusive-compose-preedit-3.tar.gz
imwayland: Be careful about cursor positionsunintrusive-compose-preedit-3
We don't want to hand out cursor positions based on the original preedit text and then tweak the text to be different.
-rw-r--r--modules/input/imwayland.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c
index a9bddd29bb..cf0b1e2144 100644
--- a/modules/input/imwayland.c
+++ b/modules/input/imwayland.c
@@ -523,7 +523,7 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
gint *cursor_pos)
{
GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
- gchar *preedit_str;
+ char *preedit_str;
if (attrs)
*attrs = NULL;
@@ -542,10 +542,8 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
}
preedit_str =
- context_wayland->current_preedit.text ? context_wayland->current_preedit.text : "";
+ tweak_preedit (context_wayland->current_preedit.text ? context_wayland->current_preedit.text : "");
- if (str)
- *str = tweak_preedit (preedit_str);
if (cursor_pos)
*cursor_pos = g_utf8_strlen (preedit_str,
context_wayland->current_preedit.cursor_begin);
@@ -566,6 +564,11 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context,
pango_attr_list_insert (*attrs, cursor);
}
}
+
+ if (str)
+ *str = preedit_str;
+ else
+ g_free (preedit_str);
}
static gboolean