[mutter/wip/carlosg/committed-and-done: 1/3] wayland: Avoid text_input state changes on idempotent changes




commit b99dbe7c9a2c490351d96233f8c44cb809a0d077
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 6 13:19:00 2022 +0200

    wayland: Avoid text_input state changes on idempotent changes
    
    On one hand we do not need for forward these through the ClutterInputFocus
    since it's already stateful. On the other hand, we will want to avoid
    possible feedback loops that will be made possible in following commits.

 src/wayland/meta-wayland-text-input.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index c892ba752f..26d7052dd5 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -416,6 +416,11 @@ text_input_set_surrounding_text (struct wl_client   *client,
 {
   MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource);
 
+  if (g_strcmp0 (text_input->surrounding.text, text) == 0 &&
+      text_input->surrounding.cursor == cursor &&
+      text_input->surrounding.anchor == anchor)
+    return;
+
   g_free (text_input->surrounding.text);
   text_input->surrounding.text = g_strdup (text);
   text_input->surrounding.cursor = cursor;
@@ -529,6 +534,12 @@ text_input_set_cursor_rectangle (struct wl_client   *client,
   if (!text_input->surface)
     return;
 
+  if (text_input->cursor_rect.x == x &&
+      text_input->cursor_rect.y == y &&
+      text_input->cursor_rect.width == width &&
+      text_input->cursor_rect.height == height)
+    return;
+
   text_input->cursor_rect = (cairo_rectangle_int_t) { x, y, width, height };
   text_input->pending_state |= META_WAYLAND_PENDING_STATE_INPUT_RECT;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]