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.
This commit is contained in:
Tudor Brindus 2020-05-12 16:34:32 -04:00 committed by Simon Ser
parent 51bbf31742
commit 8b18d389b3
2 changed files with 11 additions and 0 deletions

View file

@ -57,6 +57,11 @@ struct wlr_pointer_constraint_v1 {
struct wl_list link; // wlr_pointer_constraints_v1::constraints struct wl_list link; // wlr_pointer_constraints_v1::constraints
struct { struct {
/**
* Called when a pointer constraint's region is updated,
* post-surface-commit.
*/
struct wl_signal set_region;
struct wl_signal destroy; struct wl_signal destroy;
} events; } events;

View file

@ -116,6 +116,7 @@ static void pointer_constraint_commit(
} }
constraint->current.committed |= constraint->pending.committed; constraint->current.committed |= constraint->pending.committed;
bool updated_region = !!constraint->pending.committed;
constraint->pending.committed = 0; constraint->pending.committed = 0;
pixman_region32_clear(&constraint->region); pixman_region32_clear(&constraint->region);
@ -126,6 +127,10 @@ static void pointer_constraint_commit(
pixman_region32_copy(&constraint->region, pixman_region32_copy(&constraint->region,
&constraint->surface->input_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) { 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->type = type;
constraint->pointer_constraints = pointer_constraints; constraint->pointer_constraints = pointer_constraints;
wl_signal_init(&constraint->events.set_region);
wl_signal_init(&constraint->events.destroy); wl_signal_init(&constraint->events.destroy);
pixman_region32_init(&constraint->region); pixman_region32_init(&constraint->region);