Use byte offset for cursor_end/anchor value sent in preedit_string.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3845>
This commit is contained in:
parent
94f3bbd94b
commit
f214eb5134
@ -298,21 +298,21 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
|||||||
unsigned int anchor)
|
unsigned int anchor)
|
||||||
{
|
{
|
||||||
MetaWaylandTextInput *text_input;
|
MetaWaylandTextInput *text_input;
|
||||||
gsize pos = 0;
|
gsize cursor_pos = 0, anchor_pos = 0;
|
||||||
|
|
||||||
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
|
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);
|
g_clear_pointer (&text_input->preedit.string, g_free);
|
||||||
text_input->preedit.string = g_strdup (text);
|
text_input->preedit.string = g_strdup (text);
|
||||||
|
|
||||||
if (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.cursor = cursor_pos;
|
||||||
text_input->preedit.anchor = anchor;
|
text_input->preedit.anchor = anchor_pos;
|
||||||
text_input->preedit.changed = TRUE;
|
text_input->preedit.changed = TRUE;
|
||||||
|
|
||||||
meta_wayland_text_input_focus_defer_done (focus);
|
meta_wayland_text_input_focus_defer_done (focus);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user