diff options
author | emersion <contact@emersion.fr> | 2019-02-28 19:22:47 +0100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-02-28 23:02:06 -0500 |
commit | 88b283c55713c45968e2df5f8b89a40a0b32f720 (patch) | |
tree | 4fad7681ca82cf833920731624ce9f52df709bc0 | |
parent | tray: fix pixmap colors (diff) | |
download | sway-88b283c55713c45968e2df5f8b89a40a0b32f720.tar.gz sway-88b283c55713c45968e2df5f8b89a40a0b32f720.tar.zst sway-88b283c55713c45968e2df5f8b89a40a0b32f720.zip |
seat: don't send button release when not pressed
All seat operations except "down" eat the button pressed event and don't send
it to clients. Thus, when ending such seat operations we shouldn't send the
button released event.
This commit moves the logic used to send pressed/released into the "down"
operation.
-rw-r--r-- | include/sway/input/seat.h | 9 | ||||
-rw-r--r-- | sway/input/cursor.c | 6 | ||||
-rw-r--r-- | sway/input/seat.c | 4 | ||||
-rw-r--r-- | sway/input/seatop_down.c | 9 | ||||
-rw-r--r-- | sway/input/seatop_move_floating.c | 2 | ||||
-rw-r--r-- | sway/input/seatop_move_tiling.c | 2 | ||||
-rw-r--r-- | sway/input/seatop_resize_floating.c | 2 | ||||
-rw-r--r-- | sway/input/seatop_resize_tiling.c | 2 |
8 files changed, 18 insertions, 18 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 8fedf797..0f5dab98 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -10,7 +10,7 @@ struct sway_seat; | |||
10 | 10 | ||
11 | struct sway_seatop_impl { | 11 | struct sway_seatop_impl { |
12 | void (*motion)(struct sway_seat *seat, uint32_t time_msec); | 12 | void (*motion)(struct sway_seat *seat, uint32_t time_msec); |
13 | void (*finish)(struct sway_seat *seat); | 13 | void (*finish)(struct sway_seat *seat, uint32_t time_msec); |
14 | void (*abort)(struct sway_seat *seat); | 14 | void (*abort)(struct sway_seat *seat); |
15 | void (*unref)(struct sway_seat *seat, struct sway_container *con); | 15 | void (*unref)(struct sway_seat *seat, struct sway_container *con); |
16 | void (*render)(struct sway_seat *seat, struct sway_output *output, | 16 | void (*render)(struct sway_seat *seat, struct sway_output *output, |
@@ -185,8 +185,8 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | |||
185 | 185 | ||
186 | void drag_icon_update_position(struct sway_drag_icon *icon); | 186 | void drag_icon_update_position(struct sway_drag_icon *icon); |
187 | 187 | ||
188 | void seatop_begin_down(struct sway_seat *seat, | 188 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, |
189 | struct sway_container *con, uint32_t button, int sx, int sy); | 189 | uint32_t time_msec, uint32_t button, int sx, int sy); |
190 | 190 | ||
191 | void seatop_begin_move_floating(struct sway_seat *seat, | 191 | void seatop_begin_move_floating(struct sway_seat *seat, |
192 | struct sway_container *con, uint32_t button); | 192 | struct sway_container *con, uint32_t button); |
@@ -218,7 +218,7 @@ void seatop_motion(struct sway_seat *seat, uint32_t time_msec); | |||
218 | /** | 218 | /** |
219 | * End a seatop and apply the affects. | 219 | * End a seatop and apply the affects. |
220 | */ | 220 | */ |
221 | void seatop_finish(struct sway_seat *seat); | 221 | void seatop_finish(struct sway_seat *seat, uint32_t time_msec); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * End a seatop without applying the affects. | 224 | * End a seatop without applying the affects. |
@@ -239,5 +239,4 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con); | |||
239 | void seatop_render(struct sway_seat *seat, struct sway_output *output, | 239 | void seatop_render(struct sway_seat *seat, struct sway_output *output, |
240 | pixman_region32_t *damage); | 240 | pixman_region32_t *damage); |
241 | 241 | ||
242 | |||
243 | #endif | 242 | #endif |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 87811550..44b5ff14 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -606,8 +606,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
606 | // Handle existing seat operation | 606 | // Handle existing seat operation |
607 | if (seat_doing_seatop(seat)) { | 607 | if (seat_doing_seatop(seat)) { |
608 | if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) { | 608 | if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) { |
609 | seatop_finish(seat); | 609 | seatop_finish(seat, time_msec); |
610 | seat_pointer_notify_button(seat, time_msec, button, state); | ||
611 | } | 610 | } |
612 | if (state == WLR_BUTTON_PRESSED) { | 611 | if (state == WLR_BUTTON_PRESSED) { |
613 | state_add_button(cursor, button); | 612 | state_add_button(cursor, button); |
@@ -784,8 +783,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
784 | // Handle mousedown on a container surface | 783 | // Handle mousedown on a container surface |
785 | if (surface && cont && state == WLR_BUTTON_PRESSED) { | 784 | if (surface && cont && state == WLR_BUTTON_PRESSED) { |
786 | seat_set_focus_container(seat, cont); | 785 | seat_set_focus_container(seat, cont); |
787 | seat_pointer_notify_button(seat, time_msec, button, state); | 786 | seatop_begin_down(seat, cont, time_msec, button, sx, sy); |
788 | seatop_begin_down(seat, cont, button, sx, sy); | ||
789 | return; | 787 | return; |
790 | } | 788 | } |
791 | 789 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index a16d3f27..9888ddfc 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1211,9 +1211,9 @@ void seatop_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
1211 | } | 1211 | } |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | void seatop_finish(struct sway_seat *seat) { | 1214 | void seatop_finish(struct sway_seat *seat, uint32_t time_msec) { |
1215 | if (seat->seatop_impl && seat->seatop_impl->finish) { | 1215 | if (seat->seatop_impl && seat->seatop_impl->finish) { |
1216 | seat->seatop_impl->finish(seat); | 1216 | seat->seatop_impl->finish(seat, time_msec); |
1217 | } | 1217 | } |
1218 | free(seat->seatop_data); | 1218 | free(seat->seatop_data); |
1219 | seat->seatop_data = NULL; | 1219 | seat->seatop_data = NULL; |
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index c2256c9a..33f9b31a 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c | |||
@@ -24,7 +24,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
24 | e->moved = true; | 24 | e->moved = true; |
25 | } | 25 | } |
26 | 26 | ||
27 | static void handle_finish(struct sway_seat *seat) { | 27 | static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { |
28 | struct seatop_down_event *e = seat->seatop_data; | 28 | struct seatop_down_event *e = seat->seatop_data; |
29 | struct sway_cursor *cursor = seat->cursor; | 29 | struct sway_cursor *cursor = seat->cursor; |
30 | // Set the cursor's previous coords to the x/y at the start of the | 30 | // Set the cursor's previous coords to the x/y at the start of the |
@@ -40,6 +40,8 @@ static void handle_finish(struct sway_seat *seat) { | |||
40 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 40 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
41 | cursor_send_pointer_motion(cursor, 0, node, surface, sx, sy); | 41 | cursor_send_pointer_motion(cursor, 0, node, surface, sx, sy); |
42 | } | 42 | } |
43 | seat_pointer_notify_button(seat, time_msec, | ||
44 | seat->seatop_button, WLR_BUTTON_RELEASED); | ||
43 | } | 45 | } |
44 | 46 | ||
45 | static void handle_abort(struct sway_seat *seat) { | 47 | static void handle_abort(struct sway_seat *seat) { |
@@ -60,8 +62,8 @@ static const struct sway_seatop_impl seatop_impl = { | |||
60 | .unref = handle_unref, | 62 | .unref = handle_unref, |
61 | }; | 63 | }; |
62 | 64 | ||
63 | void seatop_begin_down(struct sway_seat *seat, | 65 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, |
64 | struct sway_container *con, uint32_t button, int sx, int sy) { | 66 | uint32_t time_msec, uint32_t button, int sx, int sy) { |
65 | seatop_abort(seat); | 67 | seatop_abort(seat); |
66 | 68 | ||
67 | struct seatop_down_event *e = | 69 | struct seatop_down_event *e = |
@@ -80,5 +82,6 @@ void seatop_begin_down(struct sway_seat *seat, | |||
80 | seat->seatop_data = e; | 82 | seat->seatop_data = e; |
81 | seat->seatop_button = button; | 83 | seat->seatop_button = button; |
82 | 84 | ||
85 | seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED); | ||
83 | container_raise_floating(con); | 86 | container_raise_floating(con); |
84 | } | 87 | } |
diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c index 08e3a5a4..8a48a968 100644 --- a/sway/input/seatop_move_floating.c +++ b/sway/input/seatop_move_floating.c | |||
@@ -17,7 +17,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
17 | desktop_damage_whole_container(e->con); | 17 | desktop_damage_whole_container(e->con); |
18 | } | 18 | } |
19 | 19 | ||
20 | static void handle_finish(struct sway_seat *seat) { | 20 | static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { |
21 | struct seatop_move_floating_event *e = seat->seatop_data; | 21 | struct seatop_move_floating_event *e = seat->seatop_data; |
22 | 22 | ||
23 | // We "move" the container to its own location | 23 | // We "move" the container to its own location |
diff --git a/sway/input/seatop_move_tiling.c b/sway/input/seatop_move_tiling.c index 1e548f5a..4b5aa81e 100644 --- a/sway/input/seatop_move_tiling.c +++ b/sway/input/seatop_move_tiling.c | |||
@@ -226,7 +226,7 @@ static bool is_parallel(enum sway_container_layout layout, | |||
226 | return layout_is_horiz == edge_is_horiz; | 226 | return layout_is_horiz == edge_is_horiz; |
227 | } | 227 | } |
228 | 228 | ||
229 | static void handle_finish(struct sway_seat *seat) { | 229 | static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { |
230 | struct seatop_move_tiling_event *e = seat->seatop_data; | 230 | struct seatop_move_tiling_event *e = seat->seatop_data; |
231 | 231 | ||
232 | if (!e->target_node) { | 232 | if (!e->target_node) { |
diff --git a/sway/input/seatop_resize_floating.c b/sway/input/seatop_resize_floating.c index 12851b40..bf6c7ab4 100644 --- a/sway/input/seatop_resize_floating.c +++ b/sway/input/seatop_resize_floating.c | |||
@@ -142,7 +142,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
142 | arrange_container(con); | 142 | arrange_container(con); |
143 | } | 143 | } |
144 | 144 | ||
145 | static void handle_finish(struct sway_seat *seat) { | 145 | static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { |
146 | cursor_set_image(seat->cursor, "left_ptr", NULL); | 146 | cursor_set_image(seat->cursor, "left_ptr", NULL); |
147 | } | 147 | } |
148 | 148 | ||
diff --git a/sway/input/seatop_resize_tiling.c b/sway/input/seatop_resize_tiling.c index cb0f723d..db32065c 100644 --- a/sway/input/seatop_resize_tiling.c +++ b/sway/input/seatop_resize_tiling.c | |||
@@ -49,7 +49,7 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec) { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | static void handle_finish(struct sway_seat *seat) { | 52 | static void handle_finish(struct sway_seat *seat, uint32_t time_msec) { |
53 | cursor_set_image(seat->cursor, "left_ptr", NULL); | 53 | cursor_set_image(seat->cursor, "left_ptr", NULL); |
54 | } | 54 | } |
55 | 55 | ||