[PATCH 3/3] compositor/shell: Set version on all wl_resources

alexl at redhat.com alexl at redhat.com
Thu May 23 10:33:45 PDT 2013


From: Alexander Larsson <alexl at redhat.com>

A few wl_resources have version != 1, we need to set this based
on the supported version and the client requested version.
---
 src/compositor.c | 22 ++++++++++++++++++++--
 src/shell.c      |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 13a6f47..1e27d51 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1671,6 +1671,21 @@ compositor_create_surface(struct wl_client *client,
 	surface->resource.data = surface;
 
 	wl_client_add_resource(client, &surface->resource);
+
+	/* The surface version depends on the requested compositor version, as
+	   that is the only way to negotiate surface versions */
+	switch (wl_resource_get_version (resource)) {
+	case 1:
+	  wl_resource_set_version (&surface->resource, 1);
+	  break;
+	case 2:
+	  wl_resource_set_version (&surface->resource, 2);
+	  break;
+	case 3:
+	default:
+	  wl_resource_set_version (&surface->resource, 3);
+	  break;
+	}
 }
 
 static void
@@ -2510,6 +2525,7 @@ bind_output(struct wl_client *client,
 
 	resource = wl_client_add_object(client,
 					&wl_output_interface, NULL, id, data);
+	wl_resource_set_version (resource, MIN(version, 2));
 
 	wl_slist_insert(&output->resource_list, &resource->link);
 	resource->destroy = unbind_resource;
@@ -2730,9 +2746,11 @@ compositor_bind(struct wl_client *client,
 		void *data, uint32_t version, uint32_t id)
 {
 	struct weston_compositor *compositor = data;
+	struct wl_resource *resource;
 
-	wl_client_add_object(client, &wl_compositor_interface,
-			     &compositor_interface, id, compositor);
+	resource = wl_client_add_object(client, &wl_compositor_interface,
+					&compositor_interface, id, compositor);
+	wl_resource_set_version (resource, MIN(version, 3));
 }
 
 static void
diff --git a/src/shell.c b/src/shell.c
index dc7cd05..1e42d6b 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3582,6 +3582,7 @@ bind_desktop_shell(struct wl_client *client,
 	resource = wl_client_add_object(client, &desktop_shell_interface,
 					&desktop_shell_implementation,
 					id, shell);
+	wl_resouce_set_version (resource, MIN(version, 2));
 
 	if (client == shell->child.client) {
 		resource->destroy = unbind_desktop_shell;
-- 
1.8.1.4



More information about the wayland-devel mailing list