This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit ea05fe0cca3a505491bce3abae398ed2a9f3357b
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 18 17:20:27 2026 -0600

    e_client, e_comp_x, e_comp_wl - a drag has to know where it started
    
    A move or resize run with no mouse event, from a key binding or from
    wl_test, did not record where it started: moveinfo.down kept whatever
    the last drag left there, zero on a window never dragged. A move jumped
    the window's top-left corner under the pointer; a resize grew from a
    size of zero and collapsed to the minimum. _e_comp_wl_evas_cb_resize()
    also read mouse.last_down[button - 1] with button 0.
    
    b2e61b1f2 fixed this by recording the start whenever there was no
    event, and was reverted in 002c93601: _NET_WM_MOVERESIZE, how GTK
    moves its client-side-decorated windows on X11, records the press
    itself and then runs the action with no event. Recording again threw
    that press away, and the drag fell back to 0,0, the left-hand head. It
    was also only half the fix: it did not record where the window was, so
    the Wayland test passed only because its window sat at 0,0.
    
    So no event now means "start from where the window and the pointer
    are", in full: position, size and pointer. Callers that do know the
    press say so, as Wayland's xdg_toplevel.move and resize already do,
    and _e_comp_x_move_resize_request() now hands the action its press
    through go_mouse. The callers that reach move or resize begin:
    
     - xdg-shell, xdg-shell v5/v6 and wl_shell: pass the press, unchanged.
     - _NET_WM_MOVERESIZE: passes its press now instead of no event.
     - key bindings, wl_test: no event, now get a full start.
     - window menu: goes through the keyboard move and resize, unaffected.
     - manual placement in e_client.c: no event, but it sets the same
       start itself, so nothing changes for it.
     - theme signals: record from the signal's button as before, and from
       where things are now when it has none.
    
    wl-client-move now drags a window that is not at 0,0. It fails on
    master and with b2e61b1f2, and passes with this. x11-csd-move and
    x11-csd-resize, on one head and on two, pass with this; x11-csd-move
    fails with b2e61b1f2. The whole suite passes, and the move, resize and
    action tests pass 10 runs out of 10.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/e_client.c                   | 27 +++++++++++++++------------
 src/bin/e_client.h                   |  3 +++
 src/bin/e_comp_wl.c                  | 31 ++++++++++++++++++++++---------
 src/bin/e_comp_x.c                   | 20 ++++++++++++++------
 src/tests/wayland/test_client_move.c | 14 ++++++++++----
 5 files changed, 64 insertions(+), 31 deletions(-)

diff --git a/src/bin/e_client.c b/src/bin/e_client.c
index ffa080914..62fbaf786 100644
--- a/src/bin/e_client.c
+++ b/src/bin/e_client.c
@@ -897,6 +897,9 @@ _e_client_move_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *ev
    return ECORE_CALLBACK_DONE;
 }
 
+/* Where a drag starts from. With a button, the press recorded it in
+ * mouse.last_down[button - 1]. Without one, it starts from where the
+ * window and the pointer are now. */
 static void
 _e_client_moveinfo_gather(E_Client *ec, const char *source)
 {
@@ -917,6 +920,10 @@ _e_client_moveinfo_gather(E_Client *ec, const char *source)
      {
         ec->moveinfo.down.mx = ec->mouse.current.mx;
         ec->moveinfo.down.my = ec->mouse.current.my;
+        ec->moveinfo.down.x = ec->x;
+        ec->moveinfo.down.y = ec->y;
+        ec->moveinfo.down.w = ec->w;
+        ec->moveinfo.down.h = ec->h;
      }
 }
 
@@ -4950,17 +4957,15 @@ e_client_act_resize_keyboard(E_Client *ec)
 E_API void
 e_client_act_move_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev)
 {
+   char source[256] = "";
+
    E_OBJECT_CHECK(ec);
    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
    if (!ec->zone) return;
    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
    if (ev)
-     {
-        char source[256];
-
-        snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
-        _e_client_moveinfo_gather(ec, source);
-     }
+     snprintf(source, sizeof(source), "mouse,down,%i", ev->button);
+   _e_client_moveinfo_gather(ec, source);
    if (!_e_client_move_begin(ec))
      return;
 
@@ -4984,18 +4989,16 @@ e_client_act_move_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED
 E_API void
 e_client_act_resize_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev)
 {
+   char source[256] = "";
+
    E_OBJECT_CHECK(ec);
    E_OBJECT_TYPE_CHECK(ec, E_CLIENT_TYPE);
    if (!ec->zone) return;
    if (ec->lock_user_size || ec->shaded || ec->shading) return;
    if (e_client_util_resizing_get(ec) || (ec->moving)) return;
    if (ev)
-     {
-        char source[256];
-
-        snprintf(source, sizeof(source) - 1, "mouse,down,%i", ev->button);
-        _e_client_moveinfo_gather(ec, source);
-     }
+     snprintf(source, sizeof(source), "mouse,down,%i", ev->button);
+   _e_client_moveinfo_gather(ec, source);
    if ((ec->mouse.current.mx > (ec->x + ec->w / 5)) &&
        (ec->mouse.current.mx < (ec->x + ec->w * 4 / 5)))
      {
diff --git a/src/bin/e_client.h b/src/bin/e_client.h
index 72d83bc12..914278705 100644
--- a/src/bin/e_client.h
+++ b/src/bin/e_client.h
@@ -837,6 +837,9 @@ E_API void e_client_comp_hidden_set(E_Client *ec, Eina_Bool hidden);
 E_API Eina_Bool e_client_border_set(E_Client *ec, const char *name);
 E_API void e_client_act_move_keyboard(E_Client *ec);
 E_API void e_client_act_resize_keyboard(E_Client *ec);
+/* ev is the press that starts the drag, its button's mouse.last_down[]
+ * already recorded; without it, the drag starts from where the window and
+ * the pointer are now. */
 E_API void e_client_act_move_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev);
 E_API void e_client_act_move_end(E_Client *ec, E_Binding_Event_Mouse_Button *ev EINA_UNUSED);
 E_API void e_client_act_resize_begin(E_Client *ec, E_Binding_Event_Mouse_Button *ev);
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index c74372920..ad7ee9dcb 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -1036,10 +1036,25 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event
 
    if (e_client_util_resizing_get(ec) && e_comp_wl->resize.edges)
      {
-        int x, y;
+        int x, y, dmx, dmy;
 
-        x = ec->mouse.last_down[ec->moveinfo.down.button - 1].w;
-        y = ec->mouse.last_down[ec->moveinfo.down.button - 1].h;
+        /* button is 0 for a resize that did not start from a press. */
+        if ((ec->moveinfo.down.button >= 1) && (ec->moveinfo.down.button <= 3))
+          {
+             int b = ec->moveinfo.down.button - 1;
+
+             x = ec->mouse.last_down[b].w;
+             y = ec->mouse.last_down[b].h;
+             dmx = ec->mouse.last_down[b].mx;
+             dmy = ec->mouse.last_down[b].my;
+          }
+        else
+          {
+             x = ec->moveinfo.down.w;
+             y = ec->moveinfo.down.h;
+             dmx = ec->moveinfo.down.mx;
+             dmy = ec->moveinfo.down.my;
+          }
         if (e_comp_object_frame_exists(ec->frame))
           e_comp_object_frame_wh_unadjust(ec->frame, x, y, &x, &y);
 
@@ -1048,13 +1063,12 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event
            case E_POINTER_RESIZE_TL:
            case E_POINTER_RESIZE_L:
            case E_POINTER_RESIZE_BL:
-             x += ec->mouse.last_down[ec->moveinfo.down.button - 1].mx -
-               ec->mouse.current.mx;
+             x += dmx - ec->mouse.current.mx;
              break;
            case E_POINTER_RESIZE_TR:
            case E_POINTER_RESIZE_R:
            case E_POINTER_RESIZE_BR:
-             x += ec->mouse.current.mx - ec->mouse.last_down[ec->moveinfo.down.button - 1].mx;
+             x += ec->mouse.current.mx - dmx;
              break;
            default:
              break;;
@@ -1064,13 +1078,12 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event
            case E_POINTER_RESIZE_TL:
            case E_POINTER_RESIZE_T:
            case E_POINTER_RESIZE_TR:
-             y += ec->mouse.last_down[ec->moveinfo.down.button - 1].my -
-               ec->mouse.current.my;
+             y += dmy - ec->mouse.current.my;
              break;
            case E_POINTER_RESIZE_BL:
            case E_POINTER_RESIZE_B:
            case E_POINTER_RESIZE_BR:
-             y += ec->mouse.current.my - ec->mouse.last_down[ec->moveinfo.down.button - 1].my;
+             y += ec->mouse.current.my - dmy;
              break;
            default:
              break;
diff --git a/src/bin/e_comp_x.c b/src/bin/e_comp_x.c
index a544738c0..da7021090 100644
--- a/src/bin/e_comp_x.c
+++ b/src/bin/e_comp_x.c
@@ -3062,6 +3062,7 @@ _e_comp_x_desktop_change(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_X_E
 static Eina_Bool
 _e_comp_x_move_resize_request(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_X_Event_Window_Move_Resize_Request *ev)
 {
+   E_Binding_Event_Mouse_Button down = { 0 };
    E_Client *ec;
 
    ec = _e_comp_x_client_find_by_window(ev->win);
@@ -3093,6 +3094,11 @@ _e_comp_x_move_resize_request(void *data EINA_UNUSED, int type EINA_UNUSED, Ecor
    ec->moveinfo.down.button = ev->button;
    ec->moveinfo.down.mx = ev->x;
    ec->moveinfo.down.my = ev->y;
+   /* The drag starts from the press recorded above, not from the pointer
+    * as the action finds it. */
+   down.button = ev->button;
+   down.canvas.x = ev->x;
+   down.canvas.y = ev->y;
 
    if (!ec->lock_user_stacking)
      evas_object_raise(ec->frame);
@@ -3102,13 +3108,14 @@ _e_comp_x_move_resize_request(void *data EINA_UNUSED, int type EINA_UNUSED, Ecor
         ec->cur_mouse_action = e_action_find("window_move");
         if (ec->cur_mouse_action)
           {
-             if ((!ec->cur_mouse_action->func.end_mouse) &&
-                 (!ec->cur_mouse_action->func.end))
+             if ((!ec->cur_mouse_action->func.go_mouse) ||
+                 ((!ec->cur_mouse_action->func.end_mouse) &&
+                  (!ec->cur_mouse_action->func.end)))
                ec->cur_mouse_action = NULL;
              if (ec->cur_mouse_action)
                {
                   e_object_ref(E_OBJECT(ec->cur_mouse_action));
-                  ec->cur_mouse_action->func.go(E_OBJECT(ec), NULL);
+                  ec->cur_mouse_action->func.go_mouse(E_OBJECT(ec), NULL, &down);
                }
           }
         return ECORE_CALLBACK_PASS_ON;
@@ -3117,13 +3124,14 @@ _e_comp_x_move_resize_request(void *data EINA_UNUSED, int type EINA_UNUSED, Ecor
    ec->cur_mouse_action = e_action_find("window_resize");
    if (ec->cur_mouse_action)
      {
-        if ((!ec->cur_mouse_action->func.end_mouse) &&
-            (!ec->cur_mouse_action->func.end))
+        if ((!ec->cur_mouse_action->func.go_mouse) ||
+            ((!ec->cur_mouse_action->func.end_mouse) &&
+             (!ec->cur_mouse_action->func.end)))
           ec->cur_mouse_action = NULL;
      }
    if (!ec->cur_mouse_action) return ECORE_CALLBACK_RENEW;
    e_object_ref(E_OBJECT(ec->cur_mouse_action));
-   ec->cur_mouse_action->func.go(E_OBJECT(ec), NULL);
+   ec->cur_mouse_action->func.go_mouse(E_OBJECT(ec), NULL, &down);
 
    if (ev->direction != E_POINTER_RESIZE_NONE)
      {
diff --git a/src/tests/wayland/test_client_move.c b/src/tests/wayland/test_client_move.c
index d9dc98753..1508ed732 100644
--- a/src/tests/wayland/test_client_move.c
+++ b/src/tests/wayland/test_client_move.c
@@ -44,6 +44,11 @@ main(void)
              c->x, c->y, x0, y0);
 
 
+   /* Away from 0,0 first: a drag that loses where the window started
+    * falls back to 0,0, and would look right from there. */
+   tk_action(tk, id, "window_move_by", "100 80");
+   c = tk_expect(tk, APP_ID);
+
    /* The pointer has to be over the window before the grab starts: a move
     * grab drags by the delta from where the pointer was when it began. */
    tk_pointer_warp(tk, c->x + (c->w / 2), c->y + (c->h / 2));
@@ -52,14 +57,15 @@ main(void)
    tk_action_end(tk, id, "window_move", NULL);
 
    c = tk_expect(tk, APP_ID);
-   if ((c->x != x0 + 60) || (c->y != y0 + 45))
-     tk_fail(tk, "a 60,45 drag put the window at +%d+%d, expected +%d+%d",
-             c->x, c->y, x0 + 60, y0 + 45);
+   if ((c->x != x0 + 160) || (c->y != y0 + 125))
+     tk_fail(tk, "a 60,45 drag from +%d+%d put the window at +%d+%d, "
+                 "expected +%d+%d", x0 + 100, y0 + 80, c->x, c->y,
+             x0 + 160, y0 + 125);
    if ((c->w != w0) || (c->h != h0))
      tk_fail(tk, "dragging resized the window to %dx%d, was %dx%d",
              c->w, c->h, w0, h0);
 
-   tk_action(tk, id, "window_move_by", "-60 -45");
+   tk_action(tk, id, "window_move_by", "-160 -125");
    c = tk_expect(tk, APP_ID);
    if ((c->x != x0) || (c->y != y0))
      tk_fail(tk, "moving back after the drag put the window at +%d+%d, "

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to