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

git pushed a commit to branch resize-buffer-leads
in repository enlightenment.

View the commit online.

commit 53c046b382a89dad04ac97ec4512afc1654f87d8
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 18:34:05 2026 -0600

    e_comp_object - let the buffer lead the frame in an interactive resize
    
    Resizing a wayland window by dragging an edge looked wrong with any
    client that takes a moment to draw, and worst with a terminal: the
    frame took the size the pointer asked for at once, and the image of
    the client is filled to its frame, so the old buffer was stretched to
    the new size until the client caught up. A terminal also rounds the
    size down to its character cells, as xdg-shell allows - the size in a
    resize configure is a maximum - so even a client that keeps up was
    shown stretched by up to a cell for most of the drag.
    
    During such a resize the frame now keeps the size of the last buffer
    the client committed. The pointer only decides which size is asked for
    with a configure, and the window changes when the client commits, to
    whatever size it chose. The edge opposite to the one dragged stays in
    place, as before, through the move that compensates a resize from the
    top or the left.
    
    This takes back "let the frame lead the buffer in an interactive
    resize". What that commit set out to fix stays fixed in another way:
    the request no longer reaches the clamp to the pixmap, so E's
    bookkeeping and the canvas agree for the whole drag, and the configure
    is sent from the size asked for instead of being worked out again
    from the pointer in e_comp_wl. It goes out once per size rather than
    once per pointer motion.
    
    That commit was found by wlcs, and the two tests that asked for it,
    XdgToplevel{Stable,V6}Test.surface_can_be_resized_interactively, fail
    again. Their client never acks the configure nor commits a buffer and
    still expects its window to have grown: they describe a compositor
    that resizes windows on its own, which is the stretching this removes.
    src/tests/wlcs/README.md says so.
    
    "client_resize" now carries the size asked for when the frame has not
    taken it. Its listeners: _e_comp_wl_evas_cb_resize() uses it;
    _e_comp_x_evas_resize_cb() is only added for X clients, which are
    resized with their window as before and never get it;
    _e_winlist_client_resize_cb() and the frame mirror read the client's
    size and ignore the event info. Shaded clients and X clients, Xwayland
    ones included, are left alone.
    
    Not covered: a drag from the top or the left that ends while the
    client still owes a buffer anchors that buffer as a resize from the
    bottom-right would, and the keyboard resize has no test.
    
    Default suite: 76 pass, 2 skip (wl-dmabuf-feedback, and
    wl-xwayland-early-map which lost its race for the X display). x11
    suite: 10 pass. The new test fails without the change, on the first
    check that the window waits for its client, and passed 20 runs in a
    row with it.
    
    Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
 src/bin/e_comp_object.c                      |  52 +++++--
 src/bin/e_comp_wl.c                          |  80 +++--------
 src/tests/wayland/meson.build                |   1 +
 src/tests/wayland/test_resize_buffer_leads.c | 201 +++++++++++++++++++++++++++
 src/tests/wlcs/README.md                     |  20 +++
 5 files changed, 283 insertions(+), 71 deletions(-)

diff --git a/src/bin/e_comp_object.c b/src/bin/e_comp_object.c
index d8ce13b9d..e9d30cd80 100644
--- a/src/bin/e_comp_object.c
+++ b/src/bin/e_comp_object.c
@@ -1130,14 +1130,40 @@ _e_comp_intercept_move(void *data, Evas_Object *obj, int x, int y)
      }
 }
 
+/* During an interactive resize a wayland client's buffer leads: the frame
+ * keeps the size of the last buffer the client committed, and only changes
+ * once it has committed another one. X clients are resized with their
+ * window. */
+static Eina_Bool
+_e_comp_object_resize_buffer_leads(const E_Comp_Object *cw)
+{
+   return e_client_util_resizing_get(cw->ec) && (!e_client_has_xwindow(cw->ec)) &&
+          (!cw->ec->shading) && (!cw->ec->shaded);
+}
+
+/* Whether a frame of this size is the one the client's buffer fills. */
+static Eina_Bool
+_e_comp_object_buffer_fits(E_Comp_Object *cw, int w, int h)
+{
+   int pw, ph;
+
+   if (!e_pixmap_size_get(cw->ec->pixmap, &pw, &ph)) return EINA_TRUE;
+   if (cw->content_w > 0)
+     pw = cw->content_w, ph = cw->content_h;
+   e_comp_object_frame_wh_unadjust(cw->smart_obj, w, h, &w, &h);
+   return (w == pw) && (h == ph);
+}
+
 static void
 _e_comp_intercept_resize(void *data, Evas_Object *obj, int w, int h)
 {
    E_Comp_Object *cw = data;
    int pw = 0, ph = 0, fw, fh, iw, ih, prev_w, prev_h, x, y;
-   Eina_Bool frame_leads;
+   Evas_Coord_Size requested;
 
    if ((w < 1) || (h < 1)) return;
+   requested.w = w;
+   requested.h = h;
    /* if frame_object does not exist, client_inset indicates CSD.
     * this means that ec->client matches cw->w/h, the opposite
     * of SSD.
@@ -1157,6 +1183,8 @@ _e_comp_intercept_resize(void *data, Evas_Object *obj, int w, int h)
              cw->ec->client.h = h - cw->client_inset.t - cw->client_inset.b;
              evas_object_smart_callback_call(obj, "client_resize", NULL);
           }
+        else if (_e_comp_object_resize_buffer_leads(cw))
+          evas_object_smart_callback_call(obj, "client_resize", &requested);
         return;
      }
    /* guarantee that fullscreen is fullscreen */
@@ -1212,6 +1240,11 @@ _e_comp_intercept_resize(void *data, Evas_Object *obj, int w, int h)
           }
         return;
      }
+   if (_e_comp_object_resize_buffer_leads(cw))
+     {
+        evas_object_smart_callback_call(obj, "client_resize", &requested);
+        if (!_e_comp_object_buffer_fits(cw, w, h)) return;
+     }
    if ((!cw->ec->internal) && e_client_util_resizing_get(cw->ec) && cw->ec->netwm.sync.request &&
        ((cw->ec->w != w) || (cw->ec->h != h)))
      {
@@ -1262,24 +1295,17 @@ _e_comp_intercept_resize(void *data, Evas_Object *obj, int w, int h)
      pw = cw->content_w, ph = cw->content_h;
    prev_w = cw->w, prev_h = cw->h;
    e_comp_object_frame_wh_adjust(obj, 0, 0, &fw, &fh);
-   /* During an interactive resize of a wayland client the frame leads and
-    * the buffer catches up a commit later: do not clamp the frame to the old
-    * buffer, but still tell the client through "client_resize". */
-   frame_leads = e_client_util_resizing_get(cw->ec) && (!e_client_has_xwindow(cw->ec));
    /* check shading and clamp to pixmap size for regular clients */
    if ((!cw->ec->shading) && (!cw->ec->shaded) && (!cw->ec->input_only) && (!cw->ec->override) &&
        (((w - fw != pw) || (h - fh != ph))))
      {
         //INF("CALLBACK: REQ(%dx%d) != CUR(%dx%d)", w - fw, h - fh, pw, ph);
         evas_object_smart_callback_call(obj, "client_resize", NULL);
-        if (!frame_leads)
-          {
-             /* flip for CSD */
-             if (cw->frame_object || cw->ec->input_only)
-               e_comp_object_frame_wh_adjust(obj, pw, ph, &w, &h);
-             else
-               w = pw, h = ph;
-          }
+        /* flip for CSD */
+        if (cw->frame_object || cw->ec->input_only)
+          e_comp_object_frame_wh_adjust(obj, pw, ph, &w, &h);
+        else
+          w = pw, h = ph;
         if ((cw->w == w) && (cw->h == h))
           {
              /* going to be a noop resize which won't trigger smart resize */
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index dd9efaa76..89b46be8a 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -40,6 +40,10 @@ static int64_t surface_id = 0;
 static Eina_List *grab_clients;
 static Eina_List *grab_cbs;
 
+/* The client size the interactive resize last sent a configure for: one
+ * goes out per size, not per pointer motion. */
+static Evas_Coord_Size _e_comp_wl_resize_requested;
+
 /* local functions */
 
 static Eina_Bool
@@ -1132,9 +1136,13 @@ _e_comp_wl_evas_cb_maximize_pre(void *data, Evas_Object *obj EINA_UNUSED, void *
      }
 }
 
+/* "client_resize" comes with the size of the frame an interactive resize is
+ * asking for, which the frame only takes once the client has drawn it, and
+ * with nothing when the frame has already been resized. */
 static void
-_e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
+_e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event)
 {
+   Evas_Coord_Size *requested = event;
    E_Client *ec;
 
    if (!(ec = data)) return;
@@ -1148,68 +1156,22 @@ _e_comp_wl_evas_cb_resize(void *data, Evas_Object *obj EINA_UNUSED, void *event
     * configure would countermand one still in flight, e.g. a maximise. */
    if (ec->comp_data->in_commit) return;
 
-   if (e_client_util_resizing_get(ec) && e_comp_wl->resize.edges)
+   if (requested)
      {
-        int x, y, dmx, dmy;
+        int w = requested->w, h = requested->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);
-
-        switch (ec->resize_mode)
-          {
-           case E_POINTER_RESIZE_TL:
-           case E_POINTER_RESIZE_L:
-           case E_POINTER_RESIZE_BL:
-             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 - dmx;
-             break;
-           default:
-             break;;
-          }
-        switch (ec->resize_mode)
-          {
-           case E_POINTER_RESIZE_TL:
-           case E_POINTER_RESIZE_T:
-           case E_POINTER_RESIZE_TR:
-             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 - dmy;
-             break;
-           default:
-             break;
-          }
-        x = E_CLAMP(x, 1, x);
-        y = E_CLAMP(y, 1, y);
+          e_comp_object_frame_wh_unadjust(ec->frame, w, h, &w, &h);
+        w = MAX(w, 1);
+        h = MAX(h, 1);
+        if ((w == _e_comp_wl_resize_requested.w) && (h == _e_comp_wl_resize_requested.h)) return;
+        _e_comp_wl_resize_requested.w = w;
+        _e_comp_wl_resize_requested.h = h;
         ec->comp_data->shell.configure_send(ec->comp_data->shell.surface,
-                                            e_comp_wl->resize.edges,
-                                            x, y);
+                                            e_comp_wl->resize.edges, w, h);
+        return;
      }
-   else
-     _e_comp_wl_configure_send(ec, 1, EINA_TRUE);
+   _e_comp_wl_configure_send(ec, 1, EINA_TRUE);
 }
 
 static void
@@ -3524,6 +3486,8 @@ _e_comp_wl_client_cb_resize_begin(void *data EINA_UNUSED, E_Client *ec)
    e_comp_wl->ptr.button_mask = 0;
    if (e_client_has_xwindow(ec)) return;
    e_comp_wl->resize.edges = 0;
+   _e_comp_wl_resize_requested.w = 0;
+   _e_comp_wl_resize_requested.h = 0;
    if (ec->keyboard_resizing) return;
    switch (ec->resize_mode)
      {
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 7e047d545..bc169e26c 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -80,6 +80,7 @@ wl_protocol_tests = [
   ['buffer-release', 'test_buffer_release.c'],
   ['buffer-hold', 'test_buffer_hold.c'],
   ['client-move', 'test_client_move.c'],
+  ['resize-buffer-leads', 'test_resize_buffer_leads.c'],
   ['pointer-frame', 'test_pointer_frame.c'],
   ['surface-unmap', 'test_surface_unmap.c'],
   ['pointer-focus', 'test_pointer_focus.c'],
diff --git a/src/tests/wayland/test_resize_buffer_leads.c b/src/tests/wayland/test_resize_buffer_leads.c
new file mode 100644
index 000000000..8410df922
--- /dev/null
+++ b/src/tests/wayland/test_resize_buffer_leads.c
@@ -0,0 +1,201 @@
+/* During an interactive resize the window follows the client's buffer, not
+ * the pointer: E asks for a size with a configure and the window changes
+ * only once the client has committed a buffer, of whatever size it chose.
+ * A terminal rounds the size down to its character cells, which xdg-shell
+ * allows: the configure of a resize is a maximum. The edge opposite to the
+ * one dragged stays where it is. */
+#include <stdio.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-resize-buffer-leads"
+#define APP_ID "e.test.resize-buffer-leads"
+#define CSD_ID "e.test.resize-buffer-leads.csd"
+#define SHADOW 16
+#define W 320
+#define H 240
+#define FOCUS WL_TEST_CLIENT_STATE_FOCUSED
+
+static struct xdg_surface *xs;
+static struct wl_surface *surface;
+static uint32_t last_serial;
+static int last_w, last_h;
+
+static void
+_xdg_configure(void *data __attribute__((unused)),
+               struct xdg_surface *xdg_surface __attribute__((unused)), uint32_t serial)
+{
+   last_serial = serial;
+}
+
+static const struct xdg_surface_listener _xdg_listener = { _xdg_configure };
+
+static void
+_toplevel_configure(void *data __attribute__((unused)), struct xdg_toplevel *top __attribute__((unused)),
+                    int32_t w, int32_t h, struct wl_array *states __attribute__((unused)))
+{
+   last_w = w;
+   last_h = h;
+}
+
+static void
+_toplevel_close(void *data __attribute__((unused)), struct xdg_toplevel *top __attribute__((unused)))
+{
+}
+
+static void
+_toplevel_bounds(void *data __attribute__((unused)), struct xdg_toplevel *top __attribute__((unused)),
+                 int32_t w __attribute__((unused)), int32_t h __attribute__((unused)))
+{
+}
+
+static void
+_toplevel_caps(void *data __attribute__((unused)), struct xdg_toplevel *top __attribute__((unused)),
+               struct wl_array *caps __attribute__((unused)))
+{
+}
+
+static const struct xdg_toplevel_listener _toplevel_listener =
+{
+   _toplevel_configure, _toplevel_close, _toplevel_bounds, _toplevel_caps
+};
+
+static void
+_paint(Tk *tk, int w, int h)
+{
+   xdg_surface_ack_configure(xs, last_serial);
+   tk_surface_paint(tk, surface, w, h);
+   tk_sync(tk);
+}
+
+static void
+_expect_configured(Tk *tk, int w, int h, const char *what)
+{
+   tk_sync(tk);
+   if ((last_w != w) || (last_h != h))
+     tk_fail(tk, "%s: configured %dx%d, not %dx%d", what, last_w, last_h, w, h);
+}
+
+static void
+_expect_geometry_of(Tk *tk, const char *app_id, int x, int y, int w, int h, const char *what)
+{
+   Tk_Client *c;
+
+   c = tk_expect(tk, app_id);
+   if ((c->x != x) || (c->y != y) || (c->w != w) || (c->h != h))
+     tk_fail(tk, "%s: the window is %dx%d+%d+%d, not %dx%d+%d+%d", what,
+             c->w, c->h, c->x, c->y, w, h, x, y);
+}
+
+static void
+_expect_geometry(Tk *tk, int x, int y, int w, int h, const char *what)
+{
+   _expect_geometry_of(tk, APP_ID, x, y, w, h, what);
+}
+
+/* A window that draws its own shadow answers every configure itself, with
+ * a surface larger than its window: the sizes compared are the window's. */
+static void
+_shadowed(Tk *tk)
+{
+   Tk_Toplevel *top;
+   Tk_Client *c;
+   unsigned int id;
+   int x, y, cw, ch;
+
+   top = tk_toplevel_new_shadowed(tk, CSD_ID, PROG, W, H, SHADOW);
+   c = tk_expect(tk, CSD_ID);
+   id = c->id;
+   tk_action(tk, id, "window_move_by", "200 150");
+   c = tk_expect(tk, CSD_ID);
+   x = c->x;
+   y = c->y;
+
+   tk_pointer_warp(tk, x + 4, y + 4);
+   tk_action(tk, id, "window_resize", NULL);
+   tk_pointer_move(tk, -30, -20);
+   tk_sync(tk);
+   tk_toplevel_configured(top, &cw, &ch, NULL);
+   if ((cw != W + 30) || (ch != H + 20))
+     tk_fail(tk, "shadowed, top-left drag: configured %dx%d, not %dx%d",
+             cw, ch, W + 30, H + 20);
+   _expect_geometry_of(tk, CSD_ID, x - 30, y - 20, W + 30, H + 20,
+                       "shadowed, top-left drag");
+   tk_action_end(tk, id, "window_resize", NULL);
+   _expect_geometry_of(tk, CSD_ID, x - 30, y - 20, W + 30, H + 20,
+                       "shadowed, top-left drag, ended");
+   tk_toplevel_del(top);
+}
+
+int
+main(void)
+{
+   struct xdg_toplevel *top;
+   Tk_Client *c;
+   unsigned int id;
+   int x, y;
+   Tk *tk;
+
+   tk = tk_connect(PROG);
+   surface = tk_surface_new(tk);
+   xs = xdg_wm_base_get_xdg_surface(tk_wm_base(tk), surface);
+   xdg_surface_add_listener(xs, &_xdg_listener, NULL);
+   top = xdg_surface_get_toplevel(xs);
+   xdg_toplevel_add_listener(top, &_toplevel_listener, NULL);
+   xdg_toplevel_set_app_id(top, APP_ID);
+   wl_surface_commit(surface);
+   tk_sync(tk);
+   _paint(tk, W, H);
+   tk_wait_states(tk, APP_ID, FOCUS, FOCUS, "a new window has the focus");
+   id = tk_expect(tk, APP_ID)->id;
+   _paint(tk, W, H);
+
+   /* Away from the top-left of the screen, so the window has room to grow
+    * that way. */
+   tk_action(tk, id, "window_move_by", "200 150");
+   c = tk_expect(tk, APP_ID);
+   x = c->x;
+   y = c->y;
+
+   tk_pointer_warp(tk, x + W - 4, y + H - 4);
+   tk_action(tk, id, "window_resize", NULL);
+   tk_pointer_move(tk, 70, 50);
+   _expect_configured(tk, W + 70, H + 50, "bottom-right drag");
+   _expect_geometry(tk, x, y, W, H, "bottom-right drag, before the client drew");
+
+   _paint(tk, W + 70, H + 50);
+   _expect_geometry(tk, x, y, W + 70, H + 50, "bottom-right drag, drawn");
+
+   /* Back to a size the window already had while the larger one is still
+    * asked for: the client must hear about it. */
+   tk_pointer_move(tk, 10, 10);
+   _expect_configured(tk, W + 80, H + 60, "bottom-right drag, further");
+   tk_pointer_move(tk, -10, -10);
+   _expect_configured(tk, W + 70, H + 50, "bottom-right drag, back");
+
+   tk_pointer_move(tk, 10, 10);
+   _expect_configured(tk, W + 80, H + 60, "bottom-right drag, further again");
+   _paint(tk, W + 76, H + 52);
+   _expect_geometry(tk, x, y, W + 76, H + 52, "bottom-right drag, rounded down");
+   tk_action_end(tk, id, "window_resize", NULL);
+   _paint(tk, W + 76, H + 52);
+   _expect_geometry(tk, x, y, W + 76, H + 52, "bottom-right drag, ended");
+
+   tk_pointer_warp(tk, x + 4, y + 4);
+   tk_action(tk, id, "window_resize", NULL);
+   tk_pointer_move(tk, -30, -20);
+   _expect_configured(tk, W + 106, H + 72, "top-left drag");
+   _expect_geometry(tk, x, y, W + 76, H + 52, "top-left drag, before the client drew");
+
+   _paint(tk, W + 100, H + 68);
+   _expect_geometry(tk, x - 24, y - 16, W + 100, H + 68, "top-left drag, rounded down");
+   tk_action_end(tk, id, "window_resize", NULL);
+   _paint(tk, W + 100, H + 68);
+   _expect_geometry(tk, x - 24, y - 16, W + 100, H + 68, "top-left drag, ended");
+
+   _shadowed(tk);
+
+   printf(PROG ": ok\n");
+   tk_disconnect(tk);
+   return 0;
+}
diff --git a/src/tests/wlcs/README.md b/src/tests/wlcs/README.md
index 85fe7b6f1..187f910f4 100644
--- a/src/tests/wlcs/README.md
+++ b/src/tests/wlcs/README.md
@@ -103,3 +103,23 @@ enable it.
 
 Remove it, and this section, once wlcs's surface builders commit before
 attaching. That is still not the case in wlcs 1.8.2.
+
+## The interactive resize tests
+
+`XdgToplevelStableTest.surface_can_be_resized_interactively` and its
+`XdgToplevelV6Test` twin are expected to fail.
+
+They drag the top-left corner of a window whose client never acknowledges a
+configure and never commits another buffer, then expect the window to have
+grown under the pointer. That is the server-driven resize of Mir, which wlcs
+was written for. E lets the buffer lead: an interactive resize only sends
+configures, and the window changes once the client has committed a buffer,
+of the size it chose. That is what
+[xdg-shell](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/stable/xdg-shell/xdg-shell.xml)
+describes - the configure of a resize is a maximum, and a state applies on
+the commit that follows its `ack_configure` - and it is the only way not to
+show a buffer at a size it was not drawn for.
+
+`wl-resize-buffer-leads` in `src/tests/wayland/` covers the behaviour E
+wants. There is no relaxation for these two: one would only make them pass
+on a code path no client takes.

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

Reply via email to