aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_move_floating.c
diff options
context:
space:
mode:
authorLibravatar Ronan Pigott <rpigott@berkeley.edu>2019-11-04 12:37:07 -0700
committerLibravatar Simon Ser <contact@emersion.fr>2019-11-04 23:53:30 +0100
commitd159b987442795fa4af5cc58fc0a6055a86aa735 (patch)
treeb12c142b450c60e5c9e9071e7dea33fbc40ac4f0 /sway/input/seatop_move_floating.c
parentfocus: do nothing on focus prev|next for workspaces (diff)
downloadsway-d159b987442795fa4af5cc58fc0a6055a86aa735.tar.gz
sway-d159b987442795fa4af5cc58fc0a6055a86aa735.tar.zst
sway-d159b987442795fa4af5cc58fc0a6055a86aa735.zip
seatop_move_floating: make container respect pointer constraint
Diffstat (limited to 'sway/input/seatop_move_floating.c')
-rw-r--r--sway/input/seatop_move_floating.c9
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
7struct seatop_move_floating_event { 7struct 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
11static void handle_button(struct sway_seat *seat, uint32_t time_msec, 12static 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,
25static void handle_motion(struct sway_seat *seat, uint32_t time_msec, 26static 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}