+ if (ivi->shell_client.resource) {
+ if (wl_resource_get_version(resource) == 1) {
+ wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "agl_shell has already been bound");
+ return;
+ }
+
+ if (ivi->shell_client_ext.resource &&
+ ivi->shell_client_ext.doas_requested) {
+
+ /* reset status in case client-ext doesn't send an
+ * explicit agl_shell_destroy request, see
+ * shell_destroy() */
+ if (ivi->shell_client.status == BOUND_FAILED)
+ ivi->shell_client.status = BOUND_OK;
+
+ wl_resource_set_implementation(resource, &agl_shell_implementation,
+ ivi, NULL);
+ ivi->shell_client.resource_ext = resource;
+
+ ivi->shell_client_ext.status = BOUND_OK;
+ agl_shell_send_bound_ok(ivi->shell_client.resource_ext);
+
+ return;
+ } else {
+ wl_resource_set_implementation(resource, &agl_shell_implementation,
+ ivi, NULL);
+ agl_shell_send_bound_fail(resource);
+ ivi->shell_client.status = BOUND_FAILED;
+ return;
+ }
+ }
+
+
+ if (wl_resource_get_version(resource) >=
+ AGL_SHELL_BOUND_OK_SINCE_VERSION) {
+ wl_resource_set_implementation(resource, &agl_shell_implementation,
+ ivi, unbind_agl_shell);
+ ivi->shell_client.resource = resource;
+ /* if we land here we'll have BOUND_OK by default,
+ but still do the assignment */
+ ivi->shell_client.status = BOUND_OK;
+ agl_shell_send_bound_ok(ivi->shell_client.resource);
+ } else {
+ /* fallback for just version 1 of the protocol */
+ wl_resource_set_implementation(resource, &agl_shell_implementation,
+ ivi, unbind_agl_shell);
+ ivi->shell_client.resource = resource;
+ }
+}
+
+static void
+bind_agl_shell_ext(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct ivi_compositor *ivi = data;
+ struct wl_resource *resource;
+
+ resource = wl_resource_create(client, &agl_shell_ext_interface, version, id);
+ if (!resource) {
+ wl_client_post_no_memory(client);