xdg: account for drag resistance in do_late_positioning()

The position where the view should be anchored can now be slightly
different from the current cursor position.

Addresses a TODO from #2009.
This commit is contained in:
John Lindgren 2024-08-02 20:18:21 -04:00 committed by Hiroaki Yamamoto
parent 4bda13d870
commit 1a339f9c7e
3 changed files with 18 additions and 12 deletions

View file

@ -93,13 +93,14 @@ do_late_positioning(struct view *view)
struct server *server = view->server;
if (server->input_mode == LAB_INPUT_STATE_MOVE
&& view == server->grabbed_view) {
/* Keep view underneath cursor */
/* TODO: resistance is not considered */
interactive_anchor_to_cursor(view, &view->pending);
/* Update grab offsets */
server->grab_x = server->seat.cursor->x;
server->grab_y = server->seat.cursor->y;
/* Anchor view to original grab position */
interactive_anchor_to_cursor(view, &view->pending,
server->grab_x, server->grab_y);
/* Next update grab offsets */
server->grab_box = view->pending;
/* Finally, move by same distance cursor has moved */
view->pending.x += server->seat.cursor->x - server->grab_x;
view->pending.y += server->seat.cursor->y - server->grab_y;
} else {
/* TODO: smart placement? */
view_compute_centered_position(view, NULL,