]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: use mouse emulation for touch when labwc menu is open
authorJens Peters <jp7677@gmail.com>
Fri, 13 Jun 2025 12:59:02 +0000 (14:59 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 14 Jun 2025 13:07:35 +0000 (14:07 +0100)
Only use the touch protocol when no labwc menu is open.
This ensure that labwc menus will be closed on first touch
down/up since cursor emulation takes care of closing a
menu.
This prevents that a labwc menu stay open during touch
interactions in native touch mode.

src/input/touch.c

index 740df726b7b066f9b9f77438edadf4cdd92abd35..eeacfdd2b33ff5ce24f15cd679a351934ccf9836 100644 (file)
@@ -35,6 +35,20 @@ touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
                return NULL;
        }
 
+       /*
+        * Do not return a surface when a labwc menu is still open.
+        * The idea is: when a client supports touch, but a labwc root or
+        * client menu is open, use mouse emulation for the first touch
+        * interaction. Mouse emulation for this first touch then runs through
+        * the normal cursor logic which closes the menu. All touch interaction
+        * after that do use the touch protocol because the menu is now closed.
+        * This matches normal pointer/mouse behavior where the first click on
+        * a surface closes a root/client menu.
+        */
+       if (seat->server->input_mode == LAB_INPUT_STATE_MENU) {
+               return NULL;
+       }
+
        /* Convert coordinates: first [0, 1] => layout, then layout => surface */
        double lx, ly;
        wlr_cursor_absolute_to_layout_coords(seat->cursor, &touch->base,