e_comp_wl: update evas's mouse position before ungrab input when pointer constrainted 06/311006/1 accepted/tizen/8.0/unified/20240513.165331
authorduna.oh <duna.oh@samsung.com>
Thu, 9 May 2024 02:24:18 +0000 (11:24 +0900)
committerduna.oh <duna.oh@samsung.com>
Mon, 13 May 2024 02:21:49 +0000 (11:21 +0900)
There is a bug that mouse out/in events are not generated for correct clients
because evas's mouse position is not updated when pointer warp is requested.
To fix this issue, call evas_event_feed_mouse_move() before ungrab input.

Change-Id: I1ad3c1d345de4ba2372061c8151f7bb54c34ba75

src/bin/e_comp.c
src/bin/e_comp_wl.c
src/bin/e_comp_wl_input.c
src/bin/e_devicemgr_input.c
src/bin/e_input_device.c

index 127e74635e8d4311487b7e84b34e43ba07b523b2..1a7012457593c3f7912da5048f74239bc79f3b01 100644 (file)
@@ -798,6 +798,8 @@ e_comp_grab_input(Eina_Bool mouse, Eina_Bool kbd)
    Eina_Bool ret = EINA_FALSE;
    Ecore_Window mwin = 0, kwin = 0;
 
+   INF("E_Comp grab_input");
+
    mouse = !!mouse;
    kbd = !!kbd;
    if (mouse || e_comp->input_mouse_grabs)
@@ -821,6 +823,8 @@ e_comp_ungrab_input(Eina_Bool mouse, Eina_Bool kbd)
 {
    Ecore_Window mwin = 0, kwin = 0;
 
+   INF("E_Comp ungrab_input");
+
    mouse = !!mouse;
    kbd = !!kbd;
    if (e_comp->input_mouse_grabs)
index 68edd4a4e7a42c1807848ace162933808868b72f..42adc1097a7810de405f644530601a47a36a8522 100644 (file)
@@ -1263,7 +1263,6 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
    struct wl_client *wc;
    Eina_List *l;
    uint32_t serial;
-   E_Comp_Config *comp_conf;
    E_Client *prev_ptr_ec;
 
    ev = event;
@@ -1285,11 +1284,9 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
 
    e_comp_wl->ptr.ec = ec;
 
-   comp_conf = e_comp_config_get();
-   if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Mouse", "In  (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
-           ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
-           e_client_util_name_get(ec));
+   ELOGF("Mouse", "In  (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
+         ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
+         e_client_util_name_get(ec));
 
    if (_e_comp_wl_check_cursor_timer_needed(ec))
      {
@@ -1312,10 +1309,7 @@ _e_comp_wl_evas_cb_mouse_in(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj
                               wl_fixed_from_int(ev->canvas.y - ec->client.y));
         ec->pointer_enter_sent = EINA_TRUE;
      }
-   if (ev->timestamp)
      wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mousein_signal, ec);
-   else
-     ELOGF("Mouse", "In. Event doesn't have timestamp. no need to send signal", NULL);
 }
 
 static void
@@ -1328,7 +1322,6 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
    Eina_List *l;
    uint32_t serial;
    Eina_Bool inside_check;
-   E_Comp_Config *comp_conf;
 
    ev = event;
 
@@ -1344,11 +1337,9 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
    struct wl_resource *surface = e_comp_wl_client_surface_get(ec);
    if (!surface) return;
 
-   comp_conf = e_comp_config_get();
-   if (comp_conf && comp_conf->input_log_enable)
-     ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
-           ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
-           e_client_util_name_get(ec));
+   ELOGF("Mouse", "Out (obj: %p, time: %d, canvas(%d, %d) output(%d, %d), name:%20s)",
+         ec, obj, ev->timestamp, ev->canvas.x, ev->canvas.y, ev->output.x, ev->output.y,
+         e_client_util_name_get(ec));
 
    if (_e_comp_wl_check_cursor_timer_needed(ec))
      {
@@ -1371,10 +1362,7 @@ _e_comp_wl_evas_cb_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
         wl_pointer_send_leave(res, serial, surface);
         ec->pointer_enter_sent = EINA_FALSE;
      }
-   if (ev->timestamp)
      wl_signal_emit(&e_comp_wl->ptr_constraints.surface_mouseout_signal, ec);
-   else
-     ELOGF("Mouse", "Out. Event doesn't have timestamp. no need to send signal", NULL);
 }
 
 static void
index 6546f04427d339fe23f092065e526fe80477fb10..593b275605765ac7646e4ca1c224c3ba1318e936 100644 (file)
@@ -829,11 +829,6 @@ _e_comp_wl_input_cb_pointer_constraints_surface_committed(struct wl_listener *li
              WRN("Pointer Constraint. Committed. hint (%d, %d)",
                  constraint->hint_x, constraint->hint_y);
           }
-
-        // Workaround: Feed mouse out/in to make sure that mouse in to correct client.
-        // Since Mouse move event doesn't generate mouse in/out if mouse(input) is grabbed,
-        // ungrab input before warping a pointer to cursor position hint.
-        e_comp_ungrab_input(1,1);
      }
 
    if (constraint->is_region_pending)
index 9658d30804b46780a9dc2cf17a8995366afea440..94d2af623fa0c0b69182427d5c57f82b24ca958b 100644 (file)
@@ -24,6 +24,23 @@ _e_devicemgr_input_pointer_warp(int x, int y)
    e_input_device_pointer_warp(NULL, x, y);
    DMWRN("The pointer warped to (%d, %d) !\n", x, y);
 
+   if (e_comp_wl_input_pointer_constraint_activated_get())
+     {
+        // update evas' mouse position to the requested warp position
+        // This generates mouse out/in to correct client.
+        DMWRN("Pointer Constraint activated. feed_mouse_move");
+        evas_event_feed_mouse_move(e_comp->evas, x, y, 0, NULL);
+     }
+
+   if (e_comp_wl_input_pointer_constraint_activated_get())
+     {
+        // Workaround: Feed mouse out/in to make sure that mouse in to correct client.
+        // Since Mouse move event doesn't generate mouse in/out if mouse(input) is grabbed,
+        // ungrab input before warping a pointer to cursor position hint.
+        DMWRN("Pointer Constraint activated. call e_comp_ungrab_input");
+        e_comp_ungrab_input(1, 1);
+     }
+
    return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
 }
 
index e3eadfa1e21ce06b9abc47e1cf47bf6c2d5eb7a4..d9080e5717b4f49f56ceea8ff7e762f2952cfe00 100644 (file)
@@ -358,12 +358,14 @@ e_input_device_pointer_warp(E_Input_Device *dev, int x, int y)
 
         if (warp_dev)
           {
-             _e_input_hook_call(E_INPUT_HOOK_POINTER_WARP, libinput_device_get_name(warp_dev->device));
-
-             seat->ptr.dx = seat->ptr.ix = x;
-             seat->ptr.dy = seat->ptr.iy = y;
-             _e_input_pointer_motion_post(warp_dev);
+             if (seat->ptr.ix != x || seat->ptr.iy != y)
+               {
+                  _e_input_hook_call(E_INPUT_HOOK_POINTER_WARP, libinput_device_get_name(warp_dev->device));
 
+                  seat->ptr.dx = seat->ptr.ix = x;
+                  seat->ptr.dy = seat->ptr.iy = y;
+                  _e_input_pointer_motion_post(warp_dev);
+               }
              found = EINA_TRUE;
           }
      }