]> git.mdlowis.com Git - proto/labwc.git/commitdiff
cursor: offset xdg invisible border when dragging outside view
authorJohan Malm <jgm323@gmail.com>
Tue, 24 May 2022 16:49:21 +0000 (17:49 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 24 May 2022 16:49:21 +0000 (17:49 +0100)
Note: view->padding was deleted in commit b279550 as the wlroots
scene-graph xdg-surface commit handler offsets the CSD invisible border.
If view->padding still existed, we could have used that, but considering
that this is probably the only place where this offset will now be
needed (because we're generating surface local coordinates), it's simpler
to just do it locally.

Related to issue #340

Written-by: @Consolatis
src/cursor.c

index 81d527ad6ef3b9c43677cedf763b2e8f3327d3e4..6c93f317d998f1093e70f1c4b32cd820b2566603 100644 (file)
@@ -302,15 +302,19 @@ process_cursor_motion(struct server *server, uint32_t time)
                 * events to the focused surface so we can keep scrolling
                 * or selecting text even if the cursor moves outside of
                 * the surface.
-                *
-                * TODO: This seems to miss calculations for invisible CSD borders.
-                *       Tracked at https://github.com/labwc/labwc/issues/340
                 */
                view = server->seat.pressed.view;
                sx = server->seat.cursor->x - view->x;
                sy = server->seat.cursor->y - view->y;
                sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
                sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy);
+               if (view->type == LAB_XDG_SHELL_VIEW && view->xdg_surface) {
+                       /* Take into account invisible CSD borders */
+                       struct wlr_box geo;
+                       wlr_xdg_surface_get_geometry(view->xdg_surface, &geo);
+                       sx += geo.x;
+                       sy += geo.y;
+               }
                wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
        } else if (surface && !input_inhibit_blocks_surface(
                        &server->seat, surface->resource)) {