diff options
-rw-r--r-- | src/wayland/meta-wayland-text-input-legacy.c | 5 | ||||
-rw-r--r-- | src/wayland/meta-wayland-text-input.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/wayland/meta-wayland-text-input-legacy.c b/src/wayland/meta-wayland-text-input-legacy.c index 3b5624c36..d8f7d1d82 100644 --- a/src/wayland/meta-wayland-text-input-legacy.c +++ b/src/wayland/meta-wayland-text-input-legacy.c @@ -103,8 +103,9 @@ meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus, struct wl_resource *resource; text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input; - before_length = offset <= 0 ? -offset : offset; - after_length = len >= before_length ? (len - before_length) : len + before_length; + before_length = ABS (MIN (offset, 0)); + after_length = MAX (0, offset + len); + g_warn_if_fail (ABS (offset) <= len); wl_resource_for_each (resource, &text_input->focus_resource_list) { diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index 13a9741c7..570dba459 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -175,8 +175,9 @@ meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus, 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; + before_length = ABS (MIN (offset, 0)); + after_length = MAX (0, offset + len); + g_warn_if_fail (ABS (offset) <= len); wl_resource_for_each (resource, &text_input->focus_resource_list) { |