[PATCH weston v1 11/17] add get_geometry & geometry request/event

Marek Chalupa mchqwerty at gmail.com
Fri Dec 5 05:36:44 PST 2014


---
 protocol/wayland-test.xml         | 11 +++++++++++
 tests/weston-test-client-helper.c | 18 ++++++++++++++++++
 tests/weston-test-client-helper.h |  6 ++++++
 tests/weston-test.c               | 23 +++++++++++++++++++++++
 4 files changed, 58 insertions(+)

diff --git a/protocol/wayland-test.xml b/protocol/wayland-test.xml
index 18b6625..b4a6bc7 100644
--- a/protocol/wayland-test.xml
+++ b/protocol/wayland-test.xml
@@ -3,6 +3,7 @@
 
   <copyright>
     Copyright © 2012 Intel Corporation
+    Copyright © 2014 Red Hat, Inc.
 
     Permission to use, copy, modify, distribute, and sell this
     software and its documentation for any purpose is hereby granted
@@ -58,5 +59,15 @@
     <event name="n_egl_buffers">
       <arg name="n" type="uint"/>
     </event>
+    <request name="get_geometry">
+      <arg name="surface" type="object" interface="wl_surface"/>
+    </request>
+    <event name="geometry">
+      <arg name="surface" type="object" interface="wl_surface"/>
+      <arg name="width" type="uint"/>
+      <arg name="height" type="uint"/>
+      <arg name="x" type="int"/>
+      <arg name="y" type="int"/>
+    </event>
   </interface>
 </protocol>
diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
index abc41e9..23b2048 100644
--- a/tests/weston-test-client-helper.c
+++ b/tests/weston-test-client-helper.c
@@ -428,9 +428,27 @@ test_handle_n_egl_buffers(void *data, struct wl_test *wl_test, uint32_t n)
 	test->n_egl_buffers = n;
 }
 
+static void
+test_handle_geometry(void *data, struct wl_test *wl_test,
+		     struct wl_surface *surface,
+		     uint32_t width, uint32_t height,
+		     int32_t x, int32_t y)
+{
+	struct test *test = data;
+
+	test->geometry.width = width;
+	test->geometry.height = height;
+	test->geometry.x = x;
+	test->geometry.y = y;
+
+	fprintf(stderr, "test-client: got geometry w: %u, h: %u, x: %d y: %d\n",
+		width, height, x, y);
+}
+
 static const struct wl_test_listener test_listener = {
 	test_handle_pointer_position,
 	test_handle_n_egl_buffers,
+	test_handle_geometry,
 };
 
 static void
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index dba47a0..3998c6d 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -64,6 +64,12 @@ struct test {
 	int pointer_x;
 	int pointer_y;
 	uint32_t n_egl_buffers;
+	struct {
+		uint32_t width;
+		uint32_t height;
+		int32_t x;
+		int32_t y;
+	} geometry;
 };
 
 struct input {
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 17c93f5..d1539e7 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -221,6 +221,28 @@ get_n_buffers(struct wl_client *client, struct wl_resource *resource)
 	wl_test_send_n_egl_buffers(resource, n_buffers);
 }
 
+static void
+get_geometry(struct wl_client *client, struct wl_resource *resource,
+	     struct wl_resource *surface_resource)
+{
+	struct weston_view *view;
+	struct weston_surface *surface =
+		wl_resource_get_user_data (surface_resource);
+
+	if (surface->configure)
+		view = wl_container_of(surface->views.next, view, surface_link);
+	else
+		view = surface->configure_private;
+
+	/* not created yet */
+	if (!view)
+		return;
+
+	wl_test_send_geometry(resource, surface_resource,
+			      surface->width, surface->height,
+			      view->geometry.x, view->geometry.y);
+}
+
 static const struct wl_test_interface test_implementation = {
 	move_surface,
 	move_pointer,
@@ -228,6 +250,7 @@ static const struct wl_test_interface test_implementation = {
 	activate_surface,
 	send_key,
 	get_n_buffers,
+	get_geometry
 };
 
 static void
-- 
2.1.0



More information about the wayland-devel mailing list