diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-05-12 16:34:32 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-13 20:38:12 +0200 |
commit | 8b18d389b3369a2797021ea6ede3b35e90edfb49 (patch) | |
tree | a02519d5c7971589043d7d642b0859949ee8c87a | |
parent | 51bbf31742a9317f20148b0eeb886b7cad23b81b (diff) |
input/pointer: notify compositor when constraint region changes
This allows a compositor to know when warping back into the region is
appropriate.
Refs swaywm/sway#5268.
-rw-r--r-- | include/wlr/types/wlr_pointer_constraints_v1.h | 5 | ||||
-rw-r--r-- | types/wlr_pointer_constraints_v1.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_pointer_constraints_v1.h b/include/wlr/types/wlr_pointer_constraints_v1.h index c13432e9..0c49e3bf 100644 --- a/include/wlr/types/wlr_pointer_constraints_v1.h +++ b/include/wlr/types/wlr_pointer_constraints_v1.h @@ -57,6 +57,11 @@ struct wlr_pointer_constraint_v1 { struct wl_list link; // wlr_pointer_constraints_v1::constraints struct { + /** + * Called when a pointer constraint's region is updated, + * post-surface-commit. + */ + struct wl_signal set_region; struct wl_signal destroy; } events; diff --git a/types/wlr_pointer_constraints_v1.c b/types/wlr_pointer_constraints_v1.c index 379333d5..eca45984 100644 --- a/types/wlr_pointer_constraints_v1.c +++ b/types/wlr_pointer_constraints_v1.c @@ -116,6 +116,7 @@ static void pointer_constraint_commit( } constraint->current.committed |= constraint->pending.committed; + bool updated_region = !!constraint->pending.committed; constraint->pending.committed = 0; pixman_region32_clear(&constraint->region); @@ -126,6 +127,10 @@ static void pointer_constraint_commit( pixman_region32_copy(&constraint->region, &constraint->surface->input_region); } + + if (updated_region) { + wlr_signal_emit_safe(&constraint->events.set_region, NULL); + } } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -209,6 +214,7 @@ static void pointer_constraint_create(struct wl_client *client, constraint->type = type; constraint->pointer_constraints = pointer_constraints; + wl_signal_init(&constraint->events.set_region); wl_signal_init(&constraint->events.destroy); pixman_region32_init(&constraint->region); |