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
This commit is contained in:
Johan Malm 2022-05-24 17:49:21 +01:00
parent 6dd290afc9
commit 81810db3b6

View file

@ -302,15 +302,19 @@ process_cursor_motion(struct server *server, uint32_t time)
* events to the focused surface so we can keep scrolling * events to the focused surface so we can keep scrolling
* or selecting text even if the cursor moves outside of * or selecting text even if the cursor moves outside of
* the surface. * 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; view = server->seat.pressed.view;
sx = server->seat.cursor->x - view->x; sx = server->seat.cursor->x - view->x;
sy = server->seat.cursor->y - view->y; sy = server->seat.cursor->y - view->y;
sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx); sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy); 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); wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
} else if (surface && !input_inhibit_blocks_surface( } else if (surface && !input_inhibit_blocks_surface(
&server->seat, surface->resource)) { &server->seat, surface->resource)) {