clutter: Enable negative offsets in delete surrounding text

The input method can assign a negative value to
clutter_input_method_delete_surrounding() to move the cursor to the left.
But Wayland protocol accepts positive values in delete_surrounding() and
GTK converts the values to the negative ones in
text_input_delete_surrounding_text_apply().

https://gitlab.gnome.org/GNOME/mutter/issues/539
This commit is contained in:
Takao Fujiwara
2019-08-15 18:47:03 +09:00
committed by Carlos Garnacho
parent 9f31e7252c
commit 2cfdbbd730
8 changed files with 34 additions and 12 deletions

View File

@ -166,17 +166,23 @@ meta_wayland_text_input_focus_defer_done (ClutterInputFocus *focus)
static void
meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
guint cursor,
int offset,
guint len)
{
MetaWaylandTextInput *text_input;
uint32_t before_length;
uint32_t after_length;
struct wl_resource *resource;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
before_length = offset <= 0 ? -offset : offset;
after_length = len >= before_length ? (len - before_length) : len + before_length;
wl_resource_for_each (resource, &text_input->focus_resource_list)
{
zwp_text_input_v3_send_delete_surrounding_text (resource, cursor, len);
zwp_text_input_v3_send_delete_surrounding_text (resource,
before_length,
after_length);
}
meta_wayland_text_input_focus_defer_done (focus);