diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-02-18 15:33:01 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-02-18 15:33:01 -0500 |
commit | 3ee5354e0f8a127e284e2d96b379b9f675f20cf7 (patch) | |
tree | 948d70db9d26192eeb65335dded9c88b4851f0f6 | |
parent | 07295ac169f39ffd1caf55e1d381e0f52a852210 (diff) | |
download | gtk+-3ee5354e0f8a127e284e2d96b379b9f675f20cf7.tar.gz |
imwayland: Be careful about cursor positions
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-- | gtk/gtkimcontextwayland.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c index 397909064d..0bee5162d9 100644 --- a/gtk/gtkimcontextwayland.c +++ b/gtk/gtkimcontextwayland.c @@ -609,7 +609,7 @@ gtk_im_context_wayland_get_preedit_string (GtkIMContext *context, int *cursor_pos) { GtkIMContextWayland *context_wayland = GTK_IM_CONTEXT_WAYLAND (context); - const char *preedit_str; + char *preedit_str; if (attrs) *attrs = NULL; @@ -628,10 +628,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); @@ -665,6 +663,10 @@ 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 |