From: Kristian Høgsberg Date: Tue, 11 Feb 2014 21:50:08 +0000 (-0800) Subject: client: Fix shell unstable version check X-Git-Tag: upstream/0.1.8~394 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=239902b323fc545c68469b465bf4af60e6655d02;p=profile%2Fivi%2Fweston-ivi-shell.git client: Fix shell unstable version check Use a static assert to catch mismatch between implementation and interface version. Fix window.c to not use XDG_SHELL_VERSION_CURRENT, which will fail to catch version mismatches. The implementation version must updated manually when the implementation is updated to use the new interface. --- diff --git a/clients/simple-egl.c b/clients/simple-egl.c index 63b3aa1..ca1c2aa 100644 --- a/clients/simple-egl.c +++ b/clients/simple-egl.c @@ -717,6 +717,12 @@ static const struct xdg_shell_listener xdg_shell_listener = { xdg_shell_ping, }; +#define XDG_VERSION 2 /* 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) @@ -731,7 +737,7 @@ registry_handle_global(void *data, struct wl_registry *registry, d->shell = wl_registry_bind(registry, name, &xdg_shell_interface, 1); xdg_shell_add_listener(d->shell, &xdg_shell_listener, d); - xdg_shell_use_unstable_version(d->shell, 1); + 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 820e8a2..2dbe7cb 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -331,6 +331,12 @@ static const struct xdg_shell_listener xdg_shell_listener = { xdg_shell_ping, }; +#define XDG_VERSION 2 /* 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) @@ -344,7 +350,7 @@ registry_handle_global(void *data, struct wl_registry *registry, } 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, 1); + xdg_shell_use_unstable_version(d->shell, XDG_VERSION); xdg_shell_add_listener(d->shell, &xdg_shell_listener, d); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, diff --git a/clients/window.c b/clients/window.c index 93aa368..400b16c 100644 --- a/clients/window.c +++ b/clients/window.c @@ -5019,6 +5019,12 @@ static const struct xdg_shell_listener xdg_shell_listener = { xdg_shell_ping, }; +#define XDG_VERSION 2 /* 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) @@ -5050,7 +5056,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, } 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_SHELL_VERSION_CURRENT); + xdg_shell_use_unstable_version(d->xdg_shell, XDG_VERSION); 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 2a82a1d..8c8e4eb 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -3635,7 +3635,7 @@ xdg_shell_unversioned_dispatch(const void *implementation, return 0; } -#define XDG_SERVER_VERSION 1 +#define XDG_SERVER_VERSION 2 static_assert(XDG_SERVER_VERSION == XDG_SHELL_VERSION_CURRENT, "shell implementation doesn't match protocol version"); diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml index d122ff5..ef755b7 100644 --- a/protocol/xdg-shell.xml +++ b/protocol/xdg-shell.xml @@ -43,7 +43,7 @@ Use this enum to check the protocol version, and it will be updated automatically. - +