libweston: Support NULL weston_pointer in init_pointer_constraint

Fix init_pointer_constraint so that it creates a valid, but inert,
resource if a NULL weston_pointer value is passed in. In that case no
constraint object is associated with the resource, but this is not an
issue since affected code can already handle NULL constraint objects.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Alexandros Frantzis 7 years ago committed by Pekka Paalanen
parent c6e2942fab
commit 0f14ae95b0
  1. 21
      libweston/input.c

@ -3572,7 +3572,7 @@ init_pointer_constraint(struct wl_resource *pointer_constraints_resource,
struct wl_resource *cr;
struct weston_pointer_constraint *constraint;
if (get_pointer_constraint_for_pointer(surface, pointer)) {
if (pointer && get_pointer_constraint_for_pointer(surface, pointer)) {
wl_resource_post_error(pointer_constraints_resource,
ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED,
"the pointer has a lock/confine request on this surface");
@ -3587,18 +3587,23 @@ init_pointer_constraint(struct wl_resource *pointer_constraints_resource,
return;
}
constraint = weston_pointer_constraint_create(surface, pointer,
region, lifetime,
cr, grab_interface);
if (constraint == NULL) {
wl_client_post_no_memory(client);
return;
if (pointer) {
constraint = weston_pointer_constraint_create(surface, pointer,
region, lifetime,
cr, grab_interface);
if (constraint == NULL) {
wl_client_post_no_memory(client);
return;
}
} else {
constraint = NULL;
}
wl_resource_set_implementation(cr, implementation, constraint,
pointer_constraint_constrain_resource_destroyed);
maybe_enable_pointer_constraint(constraint);
if (constraint)
maybe_enable_pointer_constraint(constraint);
}
static void

Loading…
Cancel
Save