diff options
author | emersion <contact@emersion.fr> | 2018-09-27 10:53:11 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-09-27 10:53:11 +0200 |
commit | d98181dab8f994d651d0a1efc9f24e5d3ca0779b (patch) | |
tree | ba46e5c11d1c881f72ed5e0399563e87939e28fd | |
parent | 792b1f5cbf98fab1ba1080b0bf7c5c592d6f0301 (diff) |
pointer-constraints: use proper wayland-scanner functions
-rw-r--r-- | include/wlr/types/wlr_pointer_constraints_v1.h | 3 | ||||
-rw-r--r-- | types/wlr_pointer_constraints_v1.c | 23 |
2 files changed, 17 insertions, 9 deletions
diff --git a/include/wlr/types/wlr_pointer_constraints_v1.h b/include/wlr/types/wlr_pointer_constraints_v1.h index 97edf0ea..98442241 100644 --- a/include/wlr/types/wlr_pointer_constraints_v1.h +++ b/include/wlr/types/wlr_pointer_constraints_v1.h @@ -85,6 +85,9 @@ struct wlr_pointer_constraint_v1 * void wlr_pointer_constraint_v1_send_activated( struct wlr_pointer_constraint_v1 *constraint); +/** + * Deactivate the constraint. May destroy the constraint. + */ void wlr_pointer_constraint_v1_send_deactivated( struct wlr_pointer_constraint_v1 *constraint); diff --git a/types/wlr_pointer_constraints_v1.c b/types/wlr_pointer_constraints_v1.c index ce69a856..196af92e 100644 --- a/types/wlr_pointer_constraints_v1.c +++ b/types/wlr_pointer_constraints_v1.c @@ -346,22 +346,27 @@ struct wlr_pointer_constraint_v1 * return NULL; } -// Thankfully zwp_confined_pointer_v1_send_{un,}confined work -// on both locked and confined pointer constraints. void wlr_pointer_constraint_v1_send_activated( struct wlr_pointer_constraint_v1 *constraint) { wlr_log(WLR_DEBUG, "constrained %p", constraint); - zwp_confined_pointer_v1_send_confined(constraint->resource); + if (constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) { + zwp_locked_pointer_v1_send_locked(constraint->resource); + } else { + zwp_confined_pointer_v1_send_confined(constraint->resource); + } } void wlr_pointer_constraint_v1_send_deactivated( struct wlr_pointer_constraint_v1 *constraint) { - if (wl_resource_get_user_data(constraint->resource)) { - wlr_log(WLR_DEBUG, "unconstrained %p", constraint); + wlr_log(WLR_DEBUG, "unconstrained %p", constraint); + if (constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) { + zwp_locked_pointer_v1_send_unlocked(constraint->resource); + } else { zwp_confined_pointer_v1_send_unconfined(constraint->resource); - if (constraint->lifetime == - ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT) { - pointer_constraint_destroy(constraint); - } + } + + if (constraint->lifetime == + ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT) { + pointer_constraint_destroy(constraint); } } |