[PATCH weston] xdg-shell: Make stable

Jasper St. Pierre jstpierre at mecheye.net
Thu Jul 17 14:57:45 PDT 2014


We've gone through enough churn of xdg-shell that we're now feeling
confident enough to commit to this much. Let's do it.

The major version number is bumped to 2 because unfortunately we need to
remove the use_unstable_version API.
---
 clients/simple-damage.c |  9 +------
 clients/simple-egl.c    |  9 +------
 clients/simple-shm.c    |  9 +------
 clients/window.c        |  9 +------
 desktop-shell/shell.c   | 67 +++++++------------------------------------------
 protocol/xdg-shell.xml  | 24 +-----------------
 6 files changed, 14 insertions(+), 113 deletions(-)

diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index d7a7c70..222808a 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -642,12 +642,6 @@ static const struct xdg_shell_listener xdg_shell_listener = {
 	xdg_shell_ping,
 };
 
-#define XDG_VERSION 3 /* The version of xdg-shell that we implement */
-#ifdef static_assert
-static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT,
-	      "Interface version doesn't match implementation version");
-#endif
-
 static void
 registry_handle_global(void *data, struct wl_registry *registry,
 		       uint32_t id, const char *interface, uint32_t version)
@@ -673,8 +667,7 @@ registry_handle_global(void *data, struct wl_registry *registry,
 					     id, &wl_scaler_interface, 2);
 	} else if (strcmp(interface, "xdg_shell") == 0) {
 		d->shell = wl_registry_bind(registry,
-					    id, &xdg_shell_interface, 1);
-		xdg_shell_use_unstable_version(d->shell, XDG_VERSION);
+					    id, &xdg_shell_interface, 2);
 		xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
 	} else if (strcmp(interface, "_wl_fullscreen_shell") == 0) {
 		d->fshell = wl_registry_bind(registry,
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 2097b4c..adb51a9 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -676,12 +676,6 @@ static const struct xdg_shell_listener xdg_shell_listener = {
 	xdg_shell_ping,
 };
 
-#define XDG_VERSION 3 /* The version of xdg-shell that we implement */
-#ifdef static_assert
-static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT,
-	      "Interface version doesn't match implementation version");
-#endif
-
 static void
 registry_handle_global(void *data, struct wl_registry *registry,
 		       uint32_t name, const char *interface, uint32_t version)
@@ -694,9 +688,8 @@ registry_handle_global(void *data, struct wl_registry *registry,
 					 &wl_compositor_interface, 1);
 	} else if (strcmp(interface, "xdg_shell") == 0) {
 		d->shell = wl_registry_bind(registry, name,
-					    &xdg_shell_interface, 1);
+					    &xdg_shell_interface, 2);
 		xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
-		xdg_shell_use_unstable_version(d->shell, XDG_VERSION);
 	} else if (strcmp(interface, "wl_seat") == 0) {
 		d->seat = wl_registry_bind(registry, name,
 					   &wl_seat_interface, 1);
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index 29abb8b..d3dd2f9 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -321,12 +321,6 @@ static const struct xdg_shell_listener xdg_shell_listener = {
 	xdg_shell_ping,
 };
 
-#define XDG_VERSION 3 /* The version of xdg-shell that we implement */
-#ifdef static_assert
-static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT,
-	      "Interface version doesn't match implementation version");
-#endif
-
 static void
 registry_handle_global(void *data, struct wl_registry *registry,
 		       uint32_t id, const char *interface, uint32_t version)
@@ -339,8 +333,7 @@ registry_handle_global(void *data, struct wl_registry *registry,
 					 id, &wl_compositor_interface, 1);
 	} else if (strcmp(interface, "xdg_shell") == 0) {
 		d->shell = wl_registry_bind(registry,
-					    id, &xdg_shell_interface, 1);
-		xdg_shell_use_unstable_version(d->shell, XDG_VERSION);
+					    id, &xdg_shell_interface, 2);
 		xdg_shell_add_listener(d->shell, &xdg_shell_listener, d);
 	} else if (strcmp(interface, "_wl_fullscreen_shell") == 0) {
 		d->fshell = wl_registry_bind(registry,
diff --git a/clients/window.c b/clients/window.c
index 1700cf9..1893a6d 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5064,12 +5064,6 @@ static const struct xdg_shell_listener xdg_shell_listener = {
 	xdg_shell_ping,
 };
 
-#define XDG_VERSION 3 /* The version of xdg-shell that we implement */
-#ifdef static_assert
-static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT,
-	      "Interface version doesn't match implementation version");
-#endif
-
 static void
 registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
 		       const char *interface, uint32_t version)
@@ -5100,8 +5094,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
 					 &wl_data_device_manager_interface, 1);
 	} else if (strcmp(interface, "xdg_shell") == 0) {
 		d->xdg_shell = wl_registry_bind(registry, id,
-						&xdg_shell_interface, 1);
-		xdg_shell_use_unstable_version(d->xdg_shell, XDG_VERSION);
+						&xdg_shell_interface, 2);
 		xdg_shell_add_listener(d->xdg_shell, &xdg_shell_listener, d);
 	} else if (strcmp(interface, "text_cursor_position") == 0) {
 		d->text_cursor_position =
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 593c7f3..86bf39f 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -3591,19 +3591,6 @@ static const struct weston_shell_client xdg_client = {
 	xdg_send_configure
 };
 
-static void
-xdg_use_unstable_version(struct wl_client *client,
-			 struct wl_resource *resource,
-			 int32_t version)
-{
-	if (version > 1) {
-		wl_resource_post_error(resource,
-				       1,
-				       "xdg-shell:: version not implemented yet.");
-		return;
-	}
-}
-
 static struct shell_surface *
 create_xdg_surface(struct shell_client *owner, void *shell,
 		   struct weston_surface *surface,
@@ -3775,48 +3762,11 @@ shell_surface_is_xdg_popup(struct shell_surface *shsurf)
 }
 
 static const struct xdg_shell_interface xdg_implementation = {
-	xdg_use_unstable_version,
 	xdg_get_xdg_surface,
 	xdg_get_xdg_popup,
 	xdg_pong
 };
 
-static int
-xdg_shell_unversioned_dispatch(const void *implementation,
-			       void *_target, uint32_t opcode,
-			       const struct wl_message *message,
-			       union wl_argument *args)
-{
-	struct wl_resource *resource = _target;
-	struct shell_client *sc = wl_resource_get_user_data(resource);
-
-	if (opcode != 0) {
-		wl_resource_post_error(resource,
-				       WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "must call use_unstable_version first");
-		return 0;
-	}
-
-#define XDG_SERVER_VERSION 3
-
-	static_assert(XDG_SERVER_VERSION == XDG_SHELL_VERSION_CURRENT,
-		      "shell implementation doesn't match protocol version");
-
-	if (args[0].i != XDG_SERVER_VERSION) {
-		wl_resource_post_error(resource,
-				       WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "incompatible version, server is %d "
-				       "client wants %d",
-				       XDG_SERVER_VERSION, args[0].i);
-		return 0;
-	}
-
-	wl_resource_set_implementation(resource, &xdg_implementation,
-				       sc, NULL);
-
-	return 1;
-}
-
 /* end of xdg-shell implementation */
 /***********************************/
 
@@ -5254,7 +5204,8 @@ handle_shell_client_destroy(struct wl_listener *listener, void *data)
 
 static struct shell_client *
 shell_client_create(struct wl_client *client, struct desktop_shell *shell,
-		    const struct wl_interface *interface, uint32_t id)
+		    const struct wl_interface *interface, uint32_t id,
+		    uint32_t version)
 {
 	struct shell_client *sc;
 
@@ -5264,7 +5215,7 @@ shell_client_create(struct wl_client *client, struct desktop_shell *shell,
 		return NULL;
 	}
 
-	sc->resource = wl_resource_create(client, interface, 1, id);
+	sc->resource = wl_resource_create(client, interface, version, id);
 	if (sc->resource == NULL) {
 		free(sc);
 		wl_client_post_no_memory(client);
@@ -5285,7 +5236,7 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 	struct desktop_shell *shell = data;
 	struct shell_client *sc;
 
-	sc = shell_client_create(client, shell, &wl_shell_interface, id);
+	sc = shell_client_create(client, shell, &wl_shell_interface, id, 1);
 	if (sc)
 		wl_resource_set_implementation(sc->resource,
 					       &shell_implementation,
@@ -5298,11 +5249,11 @@ bind_xdg_shell(struct wl_client *client, void *data, uint32_t version, uint32_t
 	struct desktop_shell *shell = data;
 	struct shell_client *sc;
 
-	sc = shell_client_create(client, shell, &xdg_shell_interface, id);
+	sc = shell_client_create(client, shell, &xdg_shell_interface, id, 2);
 	if (sc)
-		wl_resource_set_dispatcher(sc->resource,
-					   xdg_shell_unversioned_dispatch,
-					   NULL, sc, NULL);
+		wl_resource_set_implementation(sc->resource,
+					       &xdg_implementation,
+					       sc, NULL);
 }
 
 static void
@@ -6241,7 +6192,7 @@ module_init(struct weston_compositor *ec,
 				  shell, bind_shell) == NULL)
 		return -1;
 
-	if (wl_global_create(ec->wl_display, &xdg_shell_interface, 1,
+	if (wl_global_create(ec->wl_display, &xdg_shell_interface, 2,
 				  shell, bind_xdg_shell) == NULL)
 		return -1;
 
diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml
index bd36231..d5c4682 100644
--- a/protocol/xdg-shell.xml
+++ b/protocol/xdg-shell.xml
@@ -29,7 +29,7 @@
     THIS SOFTWARE.
   </copyright>
 
-  <interface name="xdg_shell" version="1">
+  <interface name="xdg_shell" version="2">
     <description summary="create desktop-style surfaces">
       This interface is implemented by servers that provide
       desktop-style user interfaces.
@@ -38,28 +38,6 @@
       a basic surface.
     </description>
 
-    <enum name="version">
-      <description summary="latest protocol version">
-	The 'current' member of this enum gives the version of the
-	protocol.  Implementations can compare this to the version
-	they implement using static_assert to ensure the protocol and
-	implementation versions match.
-      </description>
-      <entry name="current" value="3" summary="Always the latest version"/>
-    </enum>
-
-
-    <request name="use_unstable_version">
-      <description summary="enable use of this unstable version">
-	Negotiate the unstable version of the interface.  This
-	mechanism is in place to ensure client and server agree on the
-	unstable versions of the protocol that they speak or exit
-	cleanly if they don't agree.  This request will go away once
-	the xdg-shell protocol is stable.
-      </description>
-      <arg name="version" type="int"/>
-    </request>
-
     <request name="get_xdg_surface">
       <description summary="create a shell surface from a surface">
 	Create a shell surface for an existing surface.
-- 
2.0.1



More information about the wayland-devel mailing list