From 81810db3b62501e7aa5517bd72d96a94ac970b69 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Tue, 24 May 2022 17:49:21 +0100 Subject: [PATCH] cursor: offset xdg invisible border when dragging outside view 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index 81d527ad..6c93f317 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -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)) {