aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_move_floating.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seatop_move_floating.c')
-rw-r--r--sway/input/seatop_move_floating.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c
index 8a48a968..73e48964 100644
--- a/sway/input/seatop_move_floating.c
+++ b/sway/input/seatop_move_floating.c
@@ -8,45 +8,44 @@ struct seatop_move_floating_event {
8 struct sway_container *con; 8 struct sway_container *con;
9}; 9};
10 10
11static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { 11static void handle_button(struct sway_seat *seat, uint32_t time_msec,
12 struct seatop_move_floating_event *e = seat->seatop_data; 12 struct wlr_input_device *device, uint32_t button,
13 desktop_damage_whole_container(e->con); 13 enum wlr_button_state state) {
14 container_floating_translate(e->con, 14 if (seat->cursor->pressed_button_count == 0) {
15 seat->cursor->cursor->x - seat->cursor->previous.x, 15 struct seatop_move_floating_event *e = seat->seatop_data;
16 seat->cursor->cursor->y - seat->cursor->previous.y);
17 desktop_damage_whole_container(e->con);
18}
19 16
20static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { 17 // We "move" the container to its own location
21 struct seatop_move_floating_event *e = seat->seatop_data; 18 // so it discovers its output again.
19 container_floating_move_to(e->con, e->con->x, e->con->y);
22 20
23 // We "move" the container to its own location 21 seatop_begin_default(seat);
24 // so it discovers its output again. 22 }
25 container_floating_move_to(e->con, e->con->x, e->con->y);
26 cursor_set_image(seat->cursor, "left_ptr", NULL);
27} 23}
28 24
29static void handle_abort(struct sway_seat *seat) { 25static void handle_motion(struct sway_seat *seat, uint32_t time_msec,
30 cursor_set_image(seat->cursor, "left_ptr", NULL); 26 double dx, double dy) {
27 struct seatop_move_floating_event *e = seat->seatop_data;
28 desktop_damage_whole_container(e->con);
29 container_floating_translate(e->con, dx, dy);
30 desktop_damage_whole_container(e->con);
31} 31}
32 32
33static void handle_unref(struct sway_seat *seat, struct sway_container *con) { 33static void handle_unref(struct sway_seat *seat, struct sway_container *con) {
34 struct seatop_move_floating_event *e = seat->seatop_data; 34 struct seatop_move_floating_event *e = seat->seatop_data;
35 if (e->con == con) { 35 if (e->con == con) {
36 seatop_abort(seat); 36 seatop_begin_default(seat);
37 } 37 }
38} 38}
39 39
40static const struct sway_seatop_impl seatop_impl = { 40static const struct sway_seatop_impl seatop_impl = {
41 .button = handle_button,
41 .motion = handle_motion, 42 .motion = handle_motion,
42 .finish = handle_finish,
43 .abort = handle_abort,
44 .unref = handle_unref, 43 .unref = handle_unref,
45}; 44};
46 45
47void seatop_begin_move_floating(struct sway_seat *seat, 46void seatop_begin_move_floating(struct sway_seat *seat,
48 struct sway_container *con, uint32_t button) { 47 struct sway_container *con) {
49 seatop_abort(seat); 48 seatop_end(seat);
50 49
51 struct seatop_move_floating_event *e = 50 struct seatop_move_floating_event *e =
52 calloc(1, sizeof(struct seatop_move_floating_event)); 51 calloc(1, sizeof(struct seatop_move_floating_event));
@@ -57,7 +56,6 @@ void seatop_begin_move_floating(struct sway_seat *seat,
57 56
58 seat->seatop_impl = &seatop_impl; 57 seat->seatop_impl = &seatop_impl;
59 seat->seatop_data = e; 58 seat->seatop_data = e;
60 seat->seatop_button = button;
61 59
62 container_raise_floating(con); 60 container_raise_floating(con);
63 61