mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
wayland: Translate delete-surrounding properly to protocols
IBusInputContext/ClutterInputFocus/GtkIMContext all go for offset+len for their ::delete-surrounding signals, with offset being a signed int (neg. to delete towards left of selection, pos. to delete towards right of selection) and len being an unsigned int from the offset (and presumably, skipping the current selection). The text-input protocols however pass in this event two unsigned integers, one being the length of text to delete towards the left of the selection, and another the length of text to delete towards the right of the selection. To translate properly these semantics, positive offsets shouldn't account for before_length, and negative offset+len shouldn't account for after_length. The offset/length approach may of course represent deletions that are detached from the current cursor/selection, we simply delete the whole range from the cursor/selection positions then. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/517
This commit is contained in:
parent
2cfdbbd730
commit
bb5ea0580f
@ -103,8 +103,9 @@ meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
|
|||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
|
text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
|
||||||
before_length = offset <= 0 ? -offset : offset;
|
before_length = ABS (MIN (offset, 0));
|
||||||
after_length = len >= before_length ? (len - before_length) : len + before_length;
|
after_length = MAX (0, offset + len);
|
||||||
|
g_warn_if_fail (ABS (offset) <= len);
|
||||||
|
|
||||||
wl_resource_for_each (resource, &text_input->focus_resource_list)
|
wl_resource_for_each (resource, &text_input->focus_resource_list)
|
||||||
{
|
{
|
||||||
|
@ -175,8 +175,9 @@ meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
|
|||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
|
||||||
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
|
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
|
||||||
before_length = offset <= 0 ? -offset : offset;
|
before_length = ABS (MIN (offset, 0));
|
||||||
after_length = len >= before_length ? (len - before_length) : len + before_length;
|
after_length = MAX (0, offset + len);
|
||||||
|
g_warn_if_fail (ABS (offset) <= len);
|
||||||
|
|
||||||
wl_resource_for_each (resource, &text_input->focus_resource_list)
|
wl_resource_for_each (resource, &text_input->focus_resource_list)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user