[PATCH weston v2 1/5] weston-test: add device_{release/add} into protocol

Marek Chalupa mchqwerty at gmail.com
Mon Mar 30 03:37:55 PDT 2015


This request simulates device creation/destruction from evdev (libinput)

v2: added support for touch. Touch is not supported yet,
    but better be prepared

Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
---
 protocol/weston-test.xml |  6 ++++++
 tests/weston-test.c      | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/protocol/weston-test.xml b/protocol/weston-test.xml
index 17c7565..538d668 100644
--- a/protocol/weston-test.xml
+++ b/protocol/weston-test.xml
@@ -56,6 +56,12 @@
       <arg name="key" type="uint"/>
       <arg name="state" type="uint"/>
     </request>
+    <request name="device_release">
+      <arg name="device" type="string"/>
+    </request>
+    <request name="device_add">
+      <arg name="device" type="string"/>
+    </request>
     <event name="pointer_position">
       <arg name="x" type="fixed"/>
       <arg name="y" type="fixed"/>
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 649bdda..eb431f3 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -26,6 +26,7 @@
 #include <assert.h>
 #include <signal.h>
 #include <unistd.h>
+#include <string.h>
 
 #include "../src/compositor.h"
 #include "weston-test-server-protocol.h"
@@ -195,6 +196,44 @@ send_key(struct wl_client *client, struct wl_resource *resource,
 	notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC);
 }
 
+static void
+device_release(struct wl_client *client,
+	       struct wl_resource *resource, const char *device)
+{
+	struct weston_test *test = wl_resource_get_user_data(resource);
+	struct weston_seat *seat = get_seat(test);
+
+	if (strcmp(device, "pointer") == 0) {
+		weston_seat_release_pointer(seat);
+	} else if (strcmp(device, "keyboard") == 0) {
+		weston_seat_release_keyboard(seat);
+	} else if (strcmp(device, "touch") == 0) {
+		weston_seat_release_touch(seat);
+	} else if (strcmp(device, "seat") == 0) {
+		weston_seat_release(seat);
+	} else {
+		assert(0 && "Unsupported device");
+	}
+}
+
+static void
+device_add(struct wl_client *client,
+	   struct wl_resource *resource, const char *device)
+{
+	struct weston_test *test = wl_resource_get_user_data(resource);
+	struct weston_seat *seat = get_seat(test);
+
+	if (strcmp(device, "pointer") == 0) {
+		weston_seat_init_pointer(seat);
+	} else if (strcmp(device, "keyboard") == 0) {
+		weston_seat_init_keyboard(seat, NULL);
+	} else if (strcmp(device, "touch") == 0) {
+		weston_seat_init_touch(seat);
+	} else {
+		assert(0 && "Unsupported device");
+	}
+}
+
 #ifdef ENABLE_EGL
 static int
 is_egl_buffer(struct wl_resource *resource)
@@ -242,6 +281,8 @@ static const struct weston_test_interface test_implementation = {
 	send_button,
 	activate_surface,
 	send_key,
+	device_release,
+	device_add,
 	get_n_buffers,
 };
 
-- 
2.1.0



More information about the wayland-devel mailing list