summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2019-03-06 18:54:41 +1000
committerDrew DeVault <sir@cmpwn.com>2019-03-11 10:57:16 -0400
commit9bfb38521a6016042dffbe7e3242265b8134bda5 (patch)
tree4432120c30514af3e664f115c338b9a5cd5edb53
parentab1b1dab1f8a1ddb4a8b7b1e81c7506cece6a5f2 (diff)
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 0f5dab983..eb674b705 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -15,6 +15,7 @@ struct sway_seatop_impl {
void (*unref)(struct sway_seat *seat, struct sway_container *con);
void (*render)(struct sway_seat *seat, struct sway_output *output,
pixman_region32_t *damage);
+ bool allows_events;
};
struct sway_seat_device {
@@ -239,4 +240,6 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con);
void seatop_render(struct sway_seat *seat, struct sway_output *output,
pixman_region32_t *damage);
+bool seatop_allows_events(struct sway_seat *seat);
+
#endif
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index b96fde889..ef03c6aa4 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -613,7 +613,9 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
} else {
state_erase_button(cursor, button);
}
- seat_pointer_notify_button(seat, time_msec, button, state);
+ if (seatop_allows_events(seat)) {
+ seat_pointer_notify_button(seat, time_msec, button, state);
+ }
return;
}
@@ -682,7 +684,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
if (cont && resize_edge && button == BTN_LEFT &&
state == WLR_BUTTON_PRESSED && !is_floating) {
seat_set_focus_container(seat, cont);
- seat_pointer_notify_button(seat, time_msec, button, state);
seatop_begin_resize_tiling(seat, cont, button, edge);
return;
}
@@ -713,7 +714,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
}
cursor_set_image(seat->cursor, image, NULL);
seat_set_focus_container(seat, cont);
- seat_pointer_notify_button(seat, time_msec, button, state);
seatop_begin_resize_tiling(seat, cont, button, edge);
return;
}
@@ -729,7 +729,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
cont = cont->parent;
}
seat_set_focus_container(seat, cont);
- seat_pointer_notify_button(seat, time_msec, button, state);
seatop_begin_move_floating(seat, cont, button);
return;
}
@@ -740,7 +739,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
state == WLR_BUTTON_PRESSED) {
// Via border
if (button == BTN_LEFT && resize_edge != WLR_EDGE_NONE) {
- seat_pointer_notify_button(seat, time_msec, button, state);
seatop_begin_resize_floating(seat, cont, button, resize_edge);
return;
}
@@ -758,7 +756,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
WLR_EDGE_RIGHT : WLR_EDGE_LEFT;
edge |= cursor->cursor->y > floater->y + floater->height / 2 ?
WLR_EDGE_BOTTOM : WLR_EDGE_TOP;
- seat_pointer_notify_button(seat, time_msec, button, state);
seatop_begin_resize_floating(seat, floater, button, edge);
return;
}
@@ -775,8 +772,6 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
seat_set_focus(seat, node);
}
- seat_pointer_notify_button(seat, time_msec, button, state);
-
// If moving a container by it's title bar, use a threshold for the drag
if (!mod_pressed && config->tiling_drag_threshold > 0) {
seatop_begin_move_tiling_threshold(seat, cont, button);
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 3a68904bc..be5235390 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,
seat->seatop_impl->render(seat, output, damage);
}
}
+
+bool seatop_allows_events(struct sway_seat *seat) {
+ return seat->seatop_impl && seat->seatop_impl->allows_events;
+}
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index 7f3940957..895571b10 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 = {
.finish = handle_finish,
.abort = handle_abort,
.unref = handle_unref,
+ .allows_events = true,
};
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,