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 15a5ab42d2fc36969e7b5a2d3778219f72cbf4b1
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 16:21:07 2026 -0600

    wl_test - click where the pointer is during a popup grab
    
    While a popup grabs, e_comp_wl_grab_client_mouse_move() takes a
    motion outside the popup away from everything but the cursor: the
    pointer moves, and evas is not told. wl_test placed a button press at
    evas' pointer position, so a click outside a grabbing popup landed
    inside it, where the pointer was before, and nothing was dismissed. A
    real pointer is not affected: its button events carry the device's own
    position.
    
    During a grab, wl_test now presses the button where it last put the
    pointer. Outside a grab it keeps using evas' position, which is right
    when a pointer constraint holds the pointer still.
    
    wlcs's grabbed_popups_get_done_events_in_correct_order now passes, for
    xdg-shell and v6, and so do all 108 popup tests. wl-popup-nested-dismiss
    maps a grabbing menu and a grabbing submenu, clicks on another window,
    and checks that both get popup_done, the submenu first. It fails
    without this; E's dismiss order itself was already right.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/modules/wl_test/e_mod_main.c              |   8 +-
 src/tests/wayland/meson.build                 |   1 +
 src/tests/wayland/test_popup_nested_dismiss.c | 138 ++++++++++++++++++++++++++
 3 files changed, 145 insertions(+), 2 deletions(-)

diff --git a/src/modules/wl_test/e_mod_main.c b/src/modules/wl_test/e_mod_main.c
index a10992550..b77056ca1 100644
--- a/src/modules/wl_test/e_mod_main.c
+++ b/src/modules/wl_test/e_mod_main.c
@@ -461,11 +461,15 @@ _input_move_post(int device, int x, int y)
 
 /* ecore_event_add queues, so until a posted motion has been dispatched evas
  * still reports the position from before it. A button pressed in between
- * must use the posted position, or it clicks where the pointer used to be. */
+ * must use the posted position, or it clicks where the pointer used to be.
+ * So must one during a popup grab: e_comp_wl_grab_client_mouse_move()
+ * moves the pointer without telling evas, as only the popup may see it. */
 static void
 _pointer_xy_get(int *x, int *y)
 {
-   if (_posted_pending)
+   E_Client *ec = e_client_focused_get();
+
+   if (_posted_pending || (ec && e_comp_wl_client_is_grabbed(ec)))
      {
         *x = _posted_x;
         *y = _posted_y;
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 6898017ba..6f0ac3f69 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -84,6 +84,7 @@ wl_protocol_tests = [
   ['touch-moving-surface', 'test_touch_moving_surface.c'],
   ['pointer-axis120', 'test_pointer_axis120.c'],
   ['popup-dismiss', 'test_popup_dismiss.c'],
+  ['popup-nested-dismiss', 'test_popup_nested_dismiss.c'],
   ['xdg-tiled', 'test_xdg_tiled.c'],
   ['popup-reposition', 'test_popup_reposition.c'],
   ['xdg-toplevel-v6', 'test_xdg_toplevel_v6.c'],
diff --git a/src/tests/wayland/test_popup_nested_dismiss.c b/src/tests/wayland/test_popup_nested_dismiss.c
new file mode 100644
index 000000000..25de950eb
--- /dev/null
+++ b/src/tests/wayland/test_popup_nested_dismiss.c
@@ -0,0 +1,138 @@
+/* A click outside a menu with a grabbing submenu dismisses both, the
+ * submenu first, as xdg-shell requires of popup_done. */
+#include <stdio.h>
+#include <string.h>
+#include <linux/input-event-codes.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-popup-nested-dismiss"
+#define APP_ID "e.test.popup_nested_dismiss"
+
+typedef struct
+{
+   Tk *tk;
+   struct wl_surface *surface;
+   struct xdg_surface *xdg_surface;
+   struct xdg_popup *popup;
+   int configured, done;
+} Popup;
+
+static int dones;
+
+static void
+_popup_surface_configure(void *data, struct xdg_surface *s, uint32_t serial)
+{
+   Popup *p = data;
+
+   xdg_surface_ack_configure(s, serial);
+   if (!p->configured) tk_surface_paint(p->tk, p->surface, 60, 40);
+   p->configured++;
+}
+
+static const struct xdg_surface_listener _popup_surface_listener =
+{
+   _popup_surface_configure
+};
+
+static void
+_popup_configure(void *d, struct xdg_popup *x, int32_t px, int32_t py,
+                 int32_t w, int32_t h)
+{
+   (void)d; (void)x; (void)px; (void)py; (void)w; (void)h;
+}
+
+/* Records the order: 1 for the first popup_done, 2 for the second. */
+static void
+_popup_done(void *data, struct xdg_popup *x)
+{
+   Popup *p = data;
+
+   (void)x;
+   p->done = ++dones;
+}
+
+static void
+_popup_repositioned(void *d, struct xdg_popup *x, uint32_t token)
+{
+   (void)d; (void)x; (void)token;
+}
+
+static const struct xdg_popup_listener _popup_listener =
+{
+   _popup_configure, _popup_done, _popup_repositioned
+};
+
+static void
+_popup_map(Tk *tk, Popup *p, struct xdg_surface *parent, struct wl_seat *seat)
+{
+   struct xdg_positioner *pos;
+
+   pos = xdg_wm_base_create_positioner(tk_wm_base(tk));
+   xdg_positioner_set_size(pos, 60, 40);
+   xdg_positioner_set_anchor_rect(pos, 10, 10, 1, 1);
+   xdg_positioner_set_anchor(pos, XDG_POSITIONER_ANCHOR_TOP_LEFT);
+   xdg_positioner_set_gravity(pos, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
+   p->tk = tk;
+   p->surface = tk_surface_new(tk);
+   p->xdg_surface = xdg_wm_base_get_xdg_surface(tk_wm_base(tk), p->surface);
+   xdg_surface_add_listener(p->xdg_surface, &_popup_surface_listener, p);
+   p->popup = xdg_surface_get_popup(p->xdg_surface, parent, pos);
+   xdg_popup_add_listener(p->popup, &_popup_listener, p);
+   xdg_popup_grab(p->popup, seat, 0);
+   wl_surface_commit(p->surface);
+   tk_settle(tk);
+   xdg_positioner_destroy(pos);
+   if (!p->configured) tk_fail(tk, "a popup was never configured");
+}
+
+int
+main(void)
+{
+   struct wl_test *tester;
+   struct wl_seat *seat;
+   Tk_Toplevel *background, *top;
+   Popup menu, submenu;
+   Tk *tk;
+   int x, y;
+
+   memset(&menu, 0, sizeof(menu));
+   memset(&submenu, 0, sizeof(submenu));
+   tk = tk_connect(PROG);
+   seat = tk_bind(tk, &wl_seat_interface, 1);
+   tester = tk_bind(tk, &wl_test_interface, 1);
+   if ((!seat) || (!tester)) tk_fail(tk, "missing global");
+
+   background = "" APP_ID ".background", PROG, 200, 150);
+   wl_test_move_surface(tester, tk_toplevel_surface(background), 600, 400);
+   top = tk_toplevel_new(tk, APP_ID, PROG, 300, 200);
+   wl_test_move_surface(tester, tk_toplevel_surface(top), 50, 50);
+   tk_settle(tk);
+
+   /* The grab needs a press in the window. */
+   tk_surface_geometry(tk, tk_toplevel_surface(top), &x, &y, NULL, NULL);
+   tk_pointer_warp(tk, x + 150, y + 150);
+   tk_pointer_button(tk, BTN_LEFT, 1);
+   tk_pointer_button(tk, BTN_LEFT, 0);
+   tk_sync(tk);
+
+   _popup_map(tk, &menu, tk_toplevel_xdg_surface(top), seat);
+   _popup_map(tk, &submenu, menu.xdg_surface, seat);
+   if (menu.done || submenu.done)
+     tk_fail(tk, "a popup was dismissed before anything happened");
+
+   tk_surface_geometry(tk, tk_toplevel_surface(background), &x, &y, NULL, NULL);
+   tk_pointer_warp(tk, x + 100, y + 75);
+   tk_pointer_button(tk, BTN_LEFT, 1);
+   tk_pointer_button(tk, BTN_LEFT, 0);
+   tk_settle(tk);
+   if ((!menu.done) || (!submenu.done))
+     tk_fail(tk, "a click outside dismissed %s",
+             menu.done ? "the menu only" : submenu.done ? "the submenu only" : "nothing");
+   if (submenu.done != 1)
+     tk_fail(tk, "the menu was dismissed before its submenu");
+
+   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