diff options
-rw-r--r-- | sway/input/seatop_move_floating.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index 8f133c36..672e2d69 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | struct seatop_move_floating_event { | 7 | struct seatop_move_floating_event { |
8 | struct sway_container *con; | 8 | struct sway_container *con; |
9 | double dx, dy; // cursor offset in container | ||
9 | }; | 10 | }; |
10 | 11 | ||
11 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, | 12 | static void handle_button(struct sway_seat *seat, uint32_t time_msec, |
@@ -25,8 +26,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
25 | static void handle_motion(struct sway_seat *seat, uint32_t time_msec, | 26 | static void handle_motion(struct sway_seat *seat, uint32_t time_msec, |
26 | double dx, double dy) { | 27 | double dx, double dy) { |
27 | struct seatop_move_floating_event *e = seat->seatop_data; | 28 | struct seatop_move_floating_event *e = seat->seatop_data; |
29 | struct wlr_cursor *cursor = seat->cursor->cursor; | ||
28 | desktop_damage_whole_container(e->con); | 30 | desktop_damage_whole_container(e->con); |
29 | container_floating_translate(e->con, dx, dy); | 31 | container_floating_move_to(e->con, cursor->x - e->dx, cursor->y - e->dy); |
30 | desktop_damage_whole_container(e->con); | 32 | desktop_damage_whole_container(e->con); |
31 | } | 33 | } |
32 | 34 | ||
@@ -47,18 +49,21 @@ void seatop_begin_move_floating(struct sway_seat *seat, | |||
47 | struct sway_container *con) { | 49 | struct sway_container *con) { |
48 | seatop_end(seat); | 50 | seatop_end(seat); |
49 | 51 | ||
52 | struct sway_cursor *cursor = seat->cursor; | ||
50 | struct seatop_move_floating_event *e = | 53 | struct seatop_move_floating_event *e = |
51 | calloc(1, sizeof(struct seatop_move_floating_event)); | 54 | calloc(1, sizeof(struct seatop_move_floating_event)); |
52 | if (!e) { | 55 | if (!e) { |
53 | return; | 56 | return; |
54 | } | 57 | } |
55 | e->con = con; | 58 | e->con = con; |
59 | e->dx = cursor->cursor->x - con->x; | ||
60 | e->dy = cursor->cursor->y - con->y; | ||
56 | 61 | ||
57 | seat->seatop_impl = &seatop_impl; | 62 | seat->seatop_impl = &seatop_impl; |
58 | seat->seatop_data = e; | 63 | seat->seatop_data = e; |
59 | 64 | ||
60 | container_raise_floating(con); | 65 | container_raise_floating(con); |
61 | 66 | ||
62 | cursor_set_image(seat->cursor, "grab", NULL); | 67 | cursor_set_image(cursor, "grab", NULL); |
63 | wlr_seat_pointer_clear_focus(seat->wlr_seat); | 68 | wlr_seat_pointer_clear_focus(seat->wlr_seat); |
64 | } | 69 | } |