gtkimcontextwayland: Convert byte based offset to char based offset in delete_surroun...
authorAlynx Zhou <alynx.zhou@gmail.com>
Thu, 24 Nov 2022 10:18:49 +0000 (18:18 +0800)
committerAlynx Zhou <alynx.zhou@gmail.com>
Tue, 20 Dec 2022 01:51:08 +0000 (09:51 +0800)
commitad83d616c4b66a5681a239f0a2e57bb7f3220e7b
tree37acabeae2a4af2ada059123fbb714b2de915012
parent5e534306e4e5e7443253b1f54129ae1246f3a012
gtkimcontextwayland: Convert byte based offset to char based offset in delete_surrounding_text

ClutterInputFocus/GtkIMContext uses char based offset for
delete_surrounding, however, text_input_v3 uses byte based offset for
it. Currently only GTK with mutter can work correctly via text_input_v3
because they both forget to convert between char based offset and byte
based offset.

This commit fixes it in GTK by converting byte based offset to char
based offset with the UTF-8 encoded surrounding text.

Fixes <https://gitlab.gnome.org/GNOME/gtk/-/issues/4566>.
gtk/gtkimcontextwayland.c