shell: Verify agl-shell version for bound_ok/bound_fail 62/28362/1
authorMarius Vlad <marius.vlad@collabora.com>
Wed, 4 Jan 2023 14:42:43 +0000 (16:42 +0200)
committerMarius Vlad <marius.vlad@collabora.com>
Thu, 5 Jan 2023 17:16:26 +0000 (19:16 +0200)
Some additional checks to avoid cases where agl-shell is still
using the version 1 but we're checking against at least version 2 (where
we introduced some additional events). Part of the compat series.

Bug-AGL: SPEC-4667
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I4f5d34fd8b9fe6cf6b8097948afebee550f5345d

src/shell.c

index 4f564af..d9d3c2d 100644 (file)
@@ -1174,7 +1174,9 @@ shell_ready(struct wl_client *client, struct wl_resource *shell_res)
        struct ivi_output *output;
        struct ivi_surface *surface, *tmp;
 
-       if (ivi->shell_client.status == BOUND_FAILED) {
+       if (wl_resource_get_version(shell_res) >=
+           AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+           ivi->shell_client.status == BOUND_FAILED) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
                                       "agl_shell has already been bound. "
@@ -1228,8 +1230,10 @@ shell_set_background(struct wl_client *client,
        struct weston_desktop_surface *dsurface;
        struct ivi_surface *surface;
 
-       if (ivi->shell_client.status == BOUND_FAILED ||
-            ivi->shell_client.resource_ext == shell_res) {
+       if ((wl_resource_get_version(shell_res) >=
+           AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+           ivi->shell_client.status == BOUND_FAILED) ||
+           ivi->shell_client.resource_ext == shell_res) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
                                       "agl_shell has already been bound. "
@@ -1291,7 +1295,9 @@ shell_set_panel(struct wl_client *client,
        struct ivi_surface **member;
        int32_t width = 0, height = 0;
 
-       if (ivi->shell_client.status == BOUND_FAILED ||
+       if ((wl_resource_get_version(shell_res) >=
+            AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+            ivi->shell_client.status == BOUND_FAILED) ||
            ivi->shell_client.resource_ext == shell_res) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
@@ -1408,7 +1414,9 @@ shell_activate_app(struct wl_client *client,
        struct ivi_compositor *ivi = wl_resource_get_user_data(shell_res);
        struct ivi_output *output = to_ivi_output(woutput);
 
-       if (ivi->shell_client.status == BOUND_FAILED) {
+       if (wl_resource_get_version(shell_res) >=
+           AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+           ivi->shell_client.status == BOUND_FAILED) {
                wl_resource_post_error(shell_res,
                                       WL_DISPLAY_ERROR_INVALID_OBJECT,
                                       "agl_shell has already been bound. "
@@ -1453,7 +1461,8 @@ shell_destroy(struct wl_client *client, struct wl_resource *res)
        struct  ivi_compositor *ivi = wl_resource_get_user_data(res);
 
        /* reset status in case bind_fail was sent */
-       if (ivi->shell_client.status == BOUND_FAILED)
+       if (wl_resource_get_version(res) >= AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+           ivi->shell_client.status == BOUND_FAILED)
                ivi->shell_client.status = BOUND_OK;
 }
 
@@ -1594,7 +1603,9 @@ unbind_agl_shell(struct wl_resource *resource)
        ivi = wl_resource_get_user_data(resource);
 
        /* reset status to allow other clients issue legit requests */
-       if (ivi->shell_client.status == BOUND_FAILED) {
+       if (wl_resource_get_version(resource) >=
+           AGL_SHELL_BOUND_OK_SINCE_VERSION &&
+           ivi->shell_client.status == BOUND_FAILED) {
                ivi->shell_client.status = BOUND_OK;
                return;
        }