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.frant...@collabora.com>
---
Changes in v2:
 - New patch

 libweston/input.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 96cded47..390698c7 100644
--- a/libweston/input.c
+++ b/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
-- 
2.14.1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to