diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-15 14:48:28 +0100 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-11-15 16:58:20 +0300 |
commit | 024c3e4428ad4291a83d8fb0ccfbbd068f703542 (patch) | |
tree | 3d485d411e1b678426ed0c623d4d953613ca458c | |
parent | sway/server: specify wlr-layer-shell version on creation (diff) | |
download | sway-024c3e4428ad4291a83d8fb0ccfbbd068f703542.tar.gz sway-024c3e4428ad4291a83d8fb0ccfbbd068f703542.tar.zst sway-024c3e4428ad4291a83d8fb0ccfbbd068f703542.zip |
input/seat: locally compute drag icon offset
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3861
-rw-r--r-- | include/sway/input/seat.h | 1 | ||||
-rw-r--r-- | sway/input/seat.c | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e3a46872..4abe91f7 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -72,6 +72,7 @@ struct sway_drag_icon { | |||
72 | struct wl_list link; // sway_root::drag_icons | 72 | struct wl_list link; // sway_root::drag_icons |
73 | 73 | ||
74 | double x, y; // in layout-local coordinates | 74 | double x, y; // in layout-local coordinates |
75 | int dx, dy; // offset in surface-local coordinates | ||
75 | 76 | ||
76 | struct wl_listener surface_commit; | 77 | struct wl_listener surface_commit; |
77 | struct wl_listener map; | 78 | struct wl_listener map; |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 43b20779..c263eb82 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -382,8 +382,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) { | |||
382 | case WLR_DRAG_GRAB_KEYBOARD: | 382 | case WLR_DRAG_GRAB_KEYBOARD: |
383 | return; | 383 | return; |
384 | case WLR_DRAG_GRAB_KEYBOARD_POINTER: | 384 | case WLR_DRAG_GRAB_KEYBOARD_POINTER: |
385 | icon->x = cursor->x + wlr_icon->surface->sx; | 385 | icon->x = cursor->x + icon->dx; |
386 | icon->y = cursor->y + wlr_icon->surface->sy; | 386 | icon->y = cursor->y + icon->dy; |
387 | break; | 387 | break; |
388 | case WLR_DRAG_GRAB_KEYBOARD_TOUCH:; | 388 | case WLR_DRAG_GRAB_KEYBOARD_TOUCH:; |
389 | struct wlr_touch_point *point = | 389 | struct wlr_touch_point *point = |
@@ -391,8 +391,8 @@ void drag_icon_update_position(struct sway_drag_icon *icon) { | |||
391 | if (point == NULL) { | 391 | if (point == NULL) { |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | icon->x = seat->touch_x + wlr_icon->surface->sx; | 394 | icon->x = seat->touch_x + icon->dx; |
395 | icon->y = seat->touch_y + wlr_icon->surface->sy; | 395 | icon->y = seat->touch_y + icon->dy; |
396 | } | 396 | } |
397 | 397 | ||
398 | drag_icon_damage_whole(icon); | 398 | drag_icon_damage_whole(icon); |
@@ -402,6 +402,9 @@ static void drag_icon_handle_surface_commit(struct wl_listener *listener, | |||
402 | void *data) { | 402 | void *data) { |
403 | struct sway_drag_icon *icon = | 403 | struct sway_drag_icon *icon = |
404 | wl_container_of(listener, icon, surface_commit); | 404 | wl_container_of(listener, icon, surface_commit); |
405 | struct wlr_drag_icon *wlr_icon = icon->wlr_drag_icon; | ||
406 | icon->dx += wlr_icon->surface->current.dx; | ||
407 | icon->dy += wlr_icon->surface->current.dy; | ||
405 | drag_icon_update_position(icon); | 408 | drag_icon_update_position(icon); |
406 | } | 409 | } |
407 | 410 | ||