From f214eb513429b9434d88dd4fce115aef8ab977bc Mon Sep 17 00:00:00 2001 From: Orko Garai Date: Wed, 26 Jun 2024 01:42:41 -0400 Subject: [PATCH] Use byte offset for cursor_end/anchor value sent in preedit_string. Part-of: --- src/wayland/meta-wayland-text-input.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index 04ee51dba..9d7ae3e55 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -298,21 +298,21 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus, unsigned int anchor) { MetaWaylandTextInput *text_input; - gsize pos = 0; + gsize cursor_pos = 0, anchor_pos = 0; text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; - if (text) - pos = g_utf8_offset_to_pointer (text, cursor) - text; - g_clear_pointer (&text_input->preedit.string, g_free); text_input->preedit.string = g_strdup (text); if (text) - pos = g_utf8_offset_to_pointer (text, cursor) - text; + { + cursor_pos = g_utf8_offset_to_pointer (text, cursor) - text; + anchor_pos = g_utf8_offset_to_pointer (text, anchor) - text; + } - text_input->preedit.cursor = pos; - text_input->preedit.anchor = anchor; + text_input->preedit.cursor = cursor_pos; + text_input->preedit.anchor = anchor_pos; text_input->preedit.changed = TRUE; meta_wayland_text_input_focus_defer_done (focus);