[RFC PATCH weston] input: implement inert resources

Marek Chalupa mchqwerty at gmail.com
Fri Apr 10 06:56:22 PDT 2015


When we get request for new object without having the device,
mark the resource as inert

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 src/input.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/input.c b/src/input.c
index 142c670..01d6a37 100644
--- a/src/input.c
+++ b/src/input.c
@@ -43,7 +43,9 @@ empty_region(pixman_region32_t *region)
 
 static void unbind_resource(struct wl_resource *resource)
 {
-	wl_list_remove(wl_resource_get_link(resource));
+	/* we do not insert inert resources into lists */
+	if (!wl_resource_is_inert(resource))
+		wl_list_remove(wl_resource_get_link(resource));
 }
 
 WL_EXPORT void
@@ -1714,12 +1716,18 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
+	wl_resource_set_implementation(cr, &pointer_interface, seat->pointer,
+				       unbind_resource);
+
+	if (seat->pointer_device_count == 0) {
+		wl_resource_set_inert(cr);
+		return;
+	}
+
 	/* May be moved to focused list later by either
 	 * weston_pointer_set_focus or directly if this client is already
 	 * focused */
 	wl_list_insert(&seat->pointer->resource_list, wl_resource_get_link(cr));
-	wl_resource_set_implementation(cr, &pointer_interface, seat->pointer,
-				       unbind_resource);
 
 	if (seat->pointer->focus && seat->pointer->focus->surface->resource &&
 	    wl_resource_get_client(seat->pointer->focus->surface->resource) == client) {
@@ -1787,12 +1795,18 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
+	wl_resource_set_implementation(cr, &keyboard_interface,
+				       seat, unbind_resource);
+
+	if (seat->keyboard_device_count == 0) {
+		wl_resource_set_inert(cr);
+		return;
+	}
+
 	/* May be moved to focused list later by either
 	 * weston_keyboard_set_focus or directly if this client is already
 	 * focused */
 	wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr));
-	wl_resource_set_implementation(cr, &keyboard_interface,
-				       seat, unbind_resource);
 
 	if (wl_resource_get_version(cr) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) {
 		wl_keyboard_send_repeat_info(cr,
@@ -1866,6 +1880,14 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource,
 		return;
 	}
 
+	wl_resource_set_implementation(cr, &touch_interface,
+				       seat, unbind_resource);
+
+	if (seat->touch_device_count == 0) {
+		wl_resource_set_inert(cr);
+		return;
+	}
+
 	if (seat->touch->focus &&
 	    wl_resource_get_client(seat->touch->focus->surface->resource) == client) {
 		wl_list_insert(&seat->touch->resource_list,
@@ -1874,8 +1896,6 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource,
 		wl_list_insert(&seat->touch->focus_resource_list,
 			       wl_resource_get_link(cr));
 	}
-	wl_resource_set_implementation(cr, &touch_interface,
-				       seat, unbind_resource);
 }
 
 static const struct wl_seat_interface seat_interface = {
-- 
2.1.0



More information about the wayland-devel mailing list