ecore_wl2: send mouse move event when client resized 22/310522/1
authorduna.oh <duna.oh@samsung.com>
Tue, 30 Apr 2024 07:47:21 +0000 (16:47 +0900)
committerduna.oh <duna.oh@samsung.com>
Tue, 30 Apr 2024 08:09:39 +0000 (17:09 +0900)
When the window size changes, the client needs to update the pointer
position information.
Ex)
before resizing, window geom: x:0, y:560, w:500, h:520
after resizing,  window geom: x:0, y:504, w:500, h:576
we need to add 56 (= 560 - 504) to the y position of pointer.

This patch fixes the bug in the following scenario.

1. window is resized
2. user clicks the mouse button without moving the mouse.
3. wrong button is clicked because wl_pointer.button does not contain
the position information.

@tizen_only

Change-Id: I078a490dea125722dbeec6eb66f0e306ac16b121

src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index 94a8f0f..c92e1c1 100644 (file)
@@ -471,7 +471,7 @@ _ecore_wl2_input_mouse_out_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window
    ecore_event_add(ECORE_EVENT_MOUSE_OUT, ev, _input_event_mouse_io_cb_free, ev->dev);
 }
 
-static void
+void
 _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, int device)
 {
    Ecore_Event_Mouse_Move *ev;
@@ -2582,6 +2582,11 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id, unsigned int v
    input->repeat.enabled = EINA_TRUE;
    input->repeat.changed = EINA_FALSE;
 
+//TIZEN_ONLY(20240429): send mouse move event when client resized
+   input->pointer.sx = -1;
+   input->pointer.sy = -1;
+//
+
    wl_array_init(&input->data.selection.types);
    wl_array_init(&input->data.drag.types);
 
index a437188..b9126ce 100644 (file)
@@ -1052,4 +1052,7 @@ Eina_Bool _ecore_wl2_splitscreen_region_get_geometry(Ecore_Wl2_Splitscreen_Regio
 Eina_Bool _ecore_wl2_screen_aux_hint_splitscreen_helper(Ecore_Wl2_Window *win, const char *hint, const char *val);
 //
 
+//TIZEN_ONLY(20240429): send mouse move event when client resized
+void _ecore_wl2_input_mouse_move_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, int device);
+//
 #endif
index ddc7356..3125bee 100644 (file)
@@ -686,6 +686,8 @@ static void
 _tizen_position_cb_changed(void *data, struct tizen_position *tizen_position EINA_UNUSED, int32_t x, int32_t y)
 {
    Ecore_Wl2_Window *win;
+   Ecore_Wl2_Input *input;
+   int diff_geom_x, diff_geom_y, ptr_x, ptr_y;
 
    if (!(win = data)) return;
 
@@ -694,6 +696,23 @@ _tizen_position_cb_changed(void *data, struct tizen_position *tizen_position EIN
 
    if ((x != win->set_config.geometry.x) || (y != win->set_config.geometry.y))
      {
+//TIZEN_ONLY(20240429): send mouse move event when client resized
+        input = ecore_wl2_window_pointer_get(win);
+        if (input && input->pointer.sx >= 0 && input->pointer.sy >= 0)
+          {
+             diff_geom_x = win->set_config.geometry.x - x;
+             diff_geom_y = win->set_config.geometry.y - y;
+             ptr_x = input->pointer.sx + diff_geom_x;
+             ptr_y = input->pointer.sy + diff_geom_y;
+
+             ERR("[position changed] mouse_move_send x:%d, y:%d, diff_geom_x:%d, diff_geom_y:%d, prev(%d,%d) cur(%d,%d)",
+                  x, y, diff_geom_x, diff_geom_y, (int)input->pointer.sx, (int)input->pointer.sy, ptr_x, ptr_y);
+
+             input->pointer.sx = ptr_x;
+             input->pointer.sy = ptr_y;
+             _ecore_wl2_input_mouse_move_send(input, input->focus.pointer, 0);
+          }
+//
         win->set_config.geometry.x = x;
         win->set_config.geometry.y = y;
         _ecore_wl2_window_configure_send(win);