aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-03-06 18:54:41 +1000
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-03-11 10:57:16 -0400
commit9bfb38521a6016042dffbe7e3242265b8134bda5 (patch)
tree4432120c30514af3e664f115c338b9a5cd5edb53
parentstringop.c: refactor a few functions (diff)
downloadsway-9bfb38521a6016042dffbe7e3242265b8134bda5.tar.gz
sway-9bfb38521a6016042dffbe7e3242265b8134bda5.tar.zst
sway-9bfb38521a6016042dffbe7e3242265b8134bda5.zip
Don't send button events to surfaces when dragging or resizing
It turns out sending button events during all seat operations is not desirable. This patch introduces a new property `seatop_impl.allows_events` which allows each operation to define whether button events should be passed to the surface or not. The `down` seat operation is the only one that supports this. As all the other seatops don't support it, the calls to seat_pointer_notify_button prior to starting them have been removed.
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--sway/input/cursor.c11
-rw-r--r--sway/input/seat.c4
-rw-r--r--sway/input/seatop_down.c1
4 files changed, 11 insertions, 8 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 0f5dab98..eb674b70 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -15,6 +15,7 @@ struct sway_seatop_impl {
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,
17 pixman_region32_t *damage); 17 pixman_region32_t *damage);
18 bool allows_events;
18}; 19};
19 20
20struct sway_seat_device { 21struct sway_seat_device {
@@ -239,4 +240,6 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con);
239void seatop_render(struct sway_seat *seat, struct sway_output *output, 240void seatop_render(struct sway_seat *seat, struct sway_output *output,
240 pixman_region32_t *damage); 241 pixman_region32_t *damage);
241 242
243bool seatop_allows_events(struct sway_seat *seat);
244
242#endif 245#endif
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index b96fde88..ef03c6aa 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -613,7 +613,9 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
613 } else { 613 } else {
614 state_erase_button(cursor, button); 614 state_erase_button(cursor, button);
615 } 615 }
616 seat_pointer_notify_button(seat, time_msec, button, state); 616 if (seatop_allows_events(seat)) {
617 seat_pointer_notify_button(seat, time_msec, button, state);
618 }
617 return; 619 return;
618 } 620 }
619 621
@@ -682,7 +684,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
682 if (cont && resize_edge && button == BTN_LEFT && 684 if (cont && resize_edge && button == BTN_LEFT &&
683 state == WLR_BUTTON_PRESSED && !is_floating) { 685 state == WLR_BUTTON_PRESSED && !is_floating) {
684 seat_set_focus_container(seat, cont); 686 seat_set_focus_container(seat, cont);
685 seat_pointer_notify_button(seat, time_msec, button, state);
686 seatop_begin_resize_tiling(seat, cont, button, edge); 687 seatop_begin_resize_tiling(seat, cont, button, edge);
687 return; 688 return;
688 } 689 }
@@ -713,7 +714,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
713 } 714 }
714 cursor_set_image(seat->cursor, image, NULL); 715 cursor_set_image(seat->cursor, image, NULL);
715 seat_set_focus_container(seat, cont); 716 seat_set_focus_container(seat, cont);
716 seat_pointer_notify_button(seat, time_msec, button, state);
717 seatop_begin_resize_tiling(seat, cont, button, edge); 717 seatop_begin_resize_tiling(seat, cont, button, edge);
718 return; 718 return;
719 } 719 }
@@ -729,7 +729,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
729 cont = cont->parent; 729 cont = cont->parent;
730 } 730 }
731 seat_set_focus_container(seat, cont); 731 seat_set_focus_container(seat, cont);
732 seat_pointer_notify_button(seat, time_msec, button, state);
733 seatop_begin_move_floating(seat, cont, button); 732 seatop_begin_move_floating(seat, cont, button);
734 return; 733 return;
735 } 734 }
@@ -740,7 +739,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
740 state == WLR_BUTTON_PRESSED) { 739 state == WLR_BUTTON_PRESSED) {
741 // Via border 740 // Via border
742 if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) { 741 if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) {
743 seat_pointer_notify_button(seat, time_msec, button, state);
744 seatop_begin_resize_floating(seat, cont, button, resize_edge); 742 seatop_begin_resize_floating(seat, cont, button, resize_edge);
745 return; 743 return;
746 } 744 }
@@ -758,7 +756,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
758 WLR_EDGE_RIGHT : WLR_EDGE_LEFT; 756 WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
759 edge |= cursor->cursor->y > floater->y + floater->height / 2 ? 757 edge |= cursor->cursor->y > floater->y + floater->height / 2 ?
760 WLR_EDGE_BOTTOM : WLR_EDGE_TOP; 758 WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
761 seat_pointer_notify_button(seat, time_msec, button, state);
762 seatop_begin_resize_floating(seat, floater, button, edge); 759 seatop_begin_resize_floating(seat, floater, button, edge);
763 return; 760 return;
764 } 761 }
@@ -775,8 +772,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
775 seat_set_focus(seat, node); 772 seat_set_focus(seat, node);
776 } 773 }
777 774
778 seat_pointer_notify_button(seat, time_msec, button, state);
779
780 // If moving a container by it's title bar, use a threshold for the drag 775 // If moving a container by it's title bar, use a threshold for the drag
781 if (!mod_pressed && config->tiling_drag_threshold > 0) { 776 if (!mod_pressed && config->tiling_drag_threshold > 0) {
782 seatop_begin_move_tiling_threshold(seat, cont, button); 777 seatop_begin_move_tiling_threshold(seat, cont, button);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 3a68904b..be523539 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1234,3 +1234,7 @@ void seatop_render(struct sway_seat *seat, struct sway_output *output,
1234 seat->seatop_impl->render(seat, output, damage); 1234 seat->seatop_impl->render(seat, output, damage);
1235 } 1235 }
1236} 1236}
1237
1238bool seatop_allows_events(struct sway_seat *seat) {
1239 return seat->seatop_impl && seat->seatop_impl->allows_events;
1240}
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index 7f394095..895571b1 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -58,6 +58,7 @@ static const struct sway_seatop_impl seatop_impl = {
58 .finish = handle_finish, 58 .finish = handle_finish,
59 .abort = handle_abort, 59 .abort = handle_abort,
60 .unref = handle_unref, 60 .unref = handle_unref,
61 .allows_events = true,
61}; 62};
62 63
63void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, 64void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,