aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-05-26 10:05:33 -0400
committerSimon Ser <contact@emersion.fr>2020-05-26 16:24:52 +0200
commitd71fed95da5af5a489d2ea68b87a306ddc4d238d (patch)
tree12f9433510ad1827fe86d77a672b748238057766
parent34e0cad9acd88ccf18fc24d6917520cfc819abc1 (diff)
downloadsway-d71fed95da5af5a489d2ea68b87a306ddc4d238d.tar.xz
input/cursor: keep reference to cursor in constraint
set_region accepts a NULL *data, so we can't use it to reference the constraint and find the cursor through its seat. Fixes #5386.
-rw-r--r--include/sway/input/seat.h1
-rw-r--r--sway/input/cursor.c8
2 files changed, 4 insertions, 5 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index e313a206..37de1223 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -111,6 +111,7 @@ struct sway_seat {
};
struct sway_pointer_constraint {
+ struct sway_cursor *cursor;
struct wlr_pointer_constraint_v1 *constraint;
struct wl_listener set_region;
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 7b094d85..b336fcbc 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -833,9 +833,7 @@ static void handle_pointer_constraint_set_region(struct wl_listener *listener,
void *data) {
struct sway_pointer_constraint *sway_constraint =
wl_container_of(listener, sway_constraint, set_region);
- struct wlr_pointer_constraint_v1 *constraint = data;
- struct sway_seat *seat = constraint->seat->data;
- struct sway_cursor *cursor = seat->cursor;
+ struct sway_cursor *cursor = sway_constraint->cursor;
cursor->active_confine_requires_warp = true;
}
@@ -1248,8 +1246,7 @@ void handle_constraint_destroy(struct wl_listener *listener, void *data) {
struct sway_pointer_constraint *sway_constraint =
wl_container_of(listener, sway_constraint, destroy);
struct wlr_pointer_constraint_v1 *constraint = data;
- struct sway_seat *seat = constraint->seat->data;
- struct sway_cursor *cursor = seat->cursor;
+ struct sway_cursor *cursor = sway_constraint->cursor;
wl_list_remove(&sway_constraint->set_region.link);
wl_list_remove(&sway_constraint->destroy.link);
@@ -1273,6 +1270,7 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) {
struct sway_pointer_constraint *sway_constraint =
calloc(1, sizeof(struct sway_pointer_constraint));
+ sway_constraint->cursor = seat->cursor;
sway_constraint->constraint = constraint;
sway_constraint->set_region.notify = handle_pointer_constraint_set_region;