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

git pushed a commit to branch connman-backend
in repository enlightenment.

View the commit online.

commit 1aa81d103a06006c6ddb226ec2b2d41c1da9da79
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 16:15:22 2026 -0600

    tests - restack subsurfaces under the pointer
    
    wlcs fails place_above_simple and place_below_simple on E, which read
    as if a restack did not reach input. It does: this test restacks two
    overlapping subsurfaces with place_above and place_below, both ways,
    and the pointer is on the one on top every time, including when it
    stays still while the surface under it changes.
    
    The wlcs tests cannot pass as written. After place_below(moving_down,
    subsurface) both cover the point, subsurface is on top, and the second
    assertion requires the pointer to be on neither of them.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/tests/wayland/meson.build               |   1 +
 src/tests/wayland/test_subsurface_restack.c | 160 ++++++++++++++++++++++++++++
 2 files changed, 161 insertions(+)

diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 661c39ee5..b881b4b0c 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -79,6 +79,7 @@ wl_protocol_tests = [
   ['pointer-focus', 'test_pointer_focus.c'],
   ['subsurface-position', 'test_subsurface_position.c'],
   ['subsurface-input', 'test_subsurface_input.c'],
+  ['subsurface-restack', 'test_subsurface_restack.c'],
   ['window-geometry', 'test_window_geometry.c'],
   ['remap', 'test_remap.c'],
   ['configure-size', 'test_configure_size.c'],
diff --git a/src/tests/wayland/test_subsurface_restack.c b/src/tests/wayland/test_subsurface_restack.c
new file mode 100644
index 000000000..8945d44ef
--- /dev/null
+++ b/src/tests/wayland/test_subsurface_restack.c
@@ -0,0 +1,160 @@
+/* wl_subsurface.place_above and place_below restack a subsurface among its
+ * siblings when the parent commits, and the pointer finds the one on top. */
+#include <stdio.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-subsurface-restack"
+
+static struct wl_surface *entered;
+
+static void
+_enter(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+       uint32_t serial __attribute__((unused)), struct wl_surface *s,
+       wl_fixed_t x __attribute__((unused)), wl_fixed_t y __attribute__((unused)))
+{
+   entered = s;
+}
+
+static void
+_leave(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+       uint32_t serial __attribute__((unused)), struct wl_surface *s __attribute__((unused)))
+{
+   entered = NULL;
+}
+
+static void
+_motion(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+        uint32_t time __attribute__((unused)), wl_fixed_t x __attribute__((unused)),
+        wl_fixed_t y __attribute__((unused)))
+{
+}
+
+static void
+_button(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+        uint32_t serial __attribute__((unused)), uint32_t time __attribute__((unused)),
+        uint32_t button __attribute__((unused)), uint32_t state __attribute__((unused)))
+{
+}
+
+static void
+_axis(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+      uint32_t time __attribute__((unused)), uint32_t axis __attribute__((unused)),
+      wl_fixed_t value __attribute__((unused)))
+{
+}
+
+static const struct wl_pointer_listener _pointer_listener =
+{
+   _enter, _leave, _motion, _button, _axis, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+static Tk *tk;
+static struct wl_surface *ts, *first, *second;
+static int wx, wy;
+
+static const char *
+_name(struct wl_surface *s)
+{
+   if (s == ts) return "the toplevel";
+   if (s == first) return "the first subsurface";
+   if (s == second) return "the second subsurface";
+   return "no surface";
+}
+
+/* Both subsurfaces cover 10,10 of the toplevel. */
+static void
+_expect_on_top(struct wl_surface *want, const char *what)
+{
+   tk_pointer_warp(tk, wx + 150, wy + 150);
+   tk_sync(tk);
+   tk_pointer_warp(tk, wx + 10, wy + 10);
+   tk_sync(tk);
+   if (entered != want)
+     tk_fail(tk, "%s: the pointer is on %s, not on %s", what, _name(entered),
+             _name(want));
+}
+
+static void
+_frame_done(void *data, struct wl_callback *cb, uint32_t t __attribute__((unused)))
+{
+   int *done = data;
+
+   wl_callback_destroy(cb);
+   *done = 1;
+}
+
+static const struct wl_callback_listener _frame_listener = { _frame_done };
+
+/* As wlcs commits after a restack: the subsurfaces, then the parent. E
+ * lays a change out during its next render, and only then can the pointer
+ * find it. A frame done can come from a render already under way at the
+ * commit, so wait for two. */
+static void
+_commit_all(void)
+{
+   int frames, done;
+
+   wl_surface_commit(first);
+   wl_surface_commit(second);
+   for (frames = 0; frames < 2; frames++)
+     {
+        done = 0;
+        wl_surface_damage(ts, 0, 0, 200, 200);
+        wl_callback_add_listener(wl_surface_frame(ts), &_frame_listener, &done);
+        wl_surface_commit(ts);
+        while (!done)
+          if (wl_display_dispatch(tk_display(tk)) < 0)
+            tk_fail(tk, "disconnected waiting for a frame");
+     }
+}
+
+int
+main(void)
+{
+   struct wl_subcompositor *subcompositor;
+   struct wl_subsurface *sub_first, *sub_second;
+   struct wl_seat *seat;
+   Tk_Toplevel *top;
+
+   tk = tk_connect(PROG);
+   subcompositor = tk_bind(tk, &wl_subcompositor_interface, 1);
+   seat = tk_bind(tk, &wl_seat_interface, 1);
+   if ((!subcompositor) || (!seat)) tk_fail(tk, "missing global");
+   wl_pointer_add_listener(wl_seat_get_pointer(seat), &_pointer_listener, NULL);
+
+   top = tk_toplevel_new(tk, "e.test.subsurface_restack", PROG, 200, 200);
+   ts = tk_toplevel_surface(top);
+   first = tk_surface_new(tk);
+   sub_first = wl_subcompositor_get_subsurface(subcompositor, first, ts);
+   tk_surface_paint(tk, first, 50, 50);
+   second = tk_surface_new(tk);
+   sub_second = wl_subcompositor_get_subsurface(subcompositor, second, ts);
+   tk_surface_paint(tk, second, 50, 50);
+   _commit_all();
+   tk_surface_geometry(tk, ts, &wx, &wy, NULL, NULL);
+   _expect_on_top(second, "the subsurface made last");
+
+   wl_subsurface_place_below(sub_second, first);
+   _commit_all();
+   _expect_on_top(first, "the second placed below the first");
+
+   wl_subsurface_place_above(sub_second, first);
+   _commit_all();
+   _expect_on_top(second, "the second placed above the first");
+
+   wl_subsurface_place_above(sub_first, second);
+   _commit_all();
+   _expect_on_top(first, "the first placed above the second");
+
+   /* The pointer stays where it is, and the surface under it changes. */
+   wl_subsurface_place_below(sub_first, second);
+   _commit_all();
+   if (entered != second)
+     tk_fail(tk, "a still pointer is on %s, not on the second subsurface now on top",
+             _name(entered));
+
+   printf(PROG ": ok\n");
+   tk_disconnect(tk);
+   return 0;
+}

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

Reply via email to