]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor.c: use subsurface as reference for out-of-surface movement
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sat, 25 Jan 2025 20:45:54 +0000 (21:45 +0100)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 26 Jan 2025 13:22:06 +0000 (14:22 +0100)
The protocol states that the wl_pointer motion coordinates must be
relative to the focused surface (e.g. the surface that last received
a wl_pointer enter event).

Before this patch, the coordinates were relative to the toplevel
surface instead, resulting in subsurface events having the wrong
coordinates when pressing a button over a subsurface and moving
the cursor outside of that subsurface.

Fixes: #2542
src/input/cursor.c

index 5af3bd0e5420c806ff2dfbfe6e7c555497c90cc9..fdaaa59c8e90391830aa1544bee987f551c51be4 100644 (file)
@@ -455,9 +455,18 @@ process_cursor_motion_out_of_surface(struct server *server,
        assert(surface);
        int lx, ly;
 
-       if (view) {
+       if (node && wlr_subsurface_try_from_wlr_surface(surface)) {
+               wlr_scene_node_coords(node, &lx, &ly);
+       } else if (view) {
                lx = view->current.x;
                ly = view->current.y;
+               /* Take into account invisible xdg-shell CSD borders */
+               if (view->type == LAB_XDG_SHELL_VIEW) {
+                       struct wlr_box geo;
+                       wlr_xdg_surface_get_geometry(xdg_surface_from_view(view), &geo);
+                       lx -= geo.x;
+                       ly -= geo.y;
+               }
        } else if (node && wlr_layer_surface_v1_try_from_wlr_surface(surface)) {
                wlr_scene_node_coords(node, &lx, &ly);
 #if HAVE_XWAYLAND
@@ -471,13 +480,6 @@ process_cursor_motion_out_of_surface(struct server *server,
 
        *sx = server->seat.cursor->x - lx;
        *sy = server->seat.cursor->y - ly;
-       /* Take into account invisible xdg-shell CSD borders */
-       if (view && view->type == LAB_XDG_SHELL_VIEW) {
-               struct wlr_box geo;
-               wlr_xdg_surface_get_geometry(xdg_surface_from_view(view), &geo);
-               *sx += geo.x;
-               *sy += geo.y;
-       }
 
        return true;
 }