e_comp_wl: prepend mouse move event handler to prevent mouse move propagation when... 13/292013/1
authorSungjin Park <sj76.park@samsung.com>
Tue, 25 Apr 2023 11:51:34 +0000 (20:51 +0900)
committerSungjin Park <sj76.park@samsung.com>
Wed, 26 Apr 2023 07:02:19 +0000 (16:02 +0900)
Change-Id: Ic61a340f0fbab911747a46b2ff0fea352a301878
Signed-off-by: Sungjin Park <sj76.park@samsung.com>
src/bin/e_comp_wl.c

index 457761a16c4a1ea058afaeac37f00792871afd34..f531ad786f14761645008cbb52d9ffaa3e8f7e6f 100644 (file)
@@ -4430,6 +4430,37 @@ _e_comp_wl_gl_shutdown(void)
    E_FREE(e_comp_wl->evas_gl);
 }
 
+static Eina_Bool
+_e_comp_wl_cb_mouse_move_preventer(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
+{
+   static int saved_x = -1;
+   static int saved_y = -1;
+
+   E_Client *focus = e_client_focused_get();
+
+   if ((!e_comp_wl->ptr_constraints.activated) ||
+       (!focus) ||
+       (e_comp_wl->ptr_constraints.ec != focus))
+     {
+        if (saved_x != -1 || saved_y != -1)
+          {
+             e_input_device_pointer_warp(NULL, saved_x, saved_y);
+             saved_x = -1;
+             saved_y = -1;
+          }
+
+        return ECORE_CALLBACK_RENEW;
+     }
+
+   if (saved_x == -1 || saved_y == -1)
+     {
+        saved_x = ev->x;
+        saved_y = ev->y;
+     }
+
+   return ECORE_CALLBACK_DONE;
+}
+
 /* public functions */
 
 /**
@@ -4475,6 +4506,10 @@ e_comp_wl_init(void)
    if (!e_foreign_global_init(e_comp_wl->wl.disp))
      ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
 
+   /* prepend a mouse move event handler to prevent the mouse move event from being delivered to
+      the other mouse move event handlers when a pointer constraint is activated */
+   E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move_preventer, NULL);
+
    /* add event handlers to catch E events */
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE,            _e_comp_wl_cb_randr_change,        NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD,         _e_comp_wl_cb_comp_object_add,     NULL);