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

alexl at redhat.com alexl at redhat.com
Thu May 23 11:31:08 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 02e79e6..9df4014 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
@@ -2508,6 +2523,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_list_insert(&output->resource_list, &resource->link);
 	resource->destroy = unbind_resource;
@@ -2728,9 +2744,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 eb8d802..12f6b5e 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3580,6 +3580,7 @@ bind_desktop_shell(struct wl_client *client,
 	resource = wl_client_add_object(client, &desktop_shell_interface,
 					&desktop_shell_implementation,
 					id, shell);
+	wl_resource_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