+static void
+unbind_agl_shell_desktop(struct wl_resource *resource)
+{
+ struct desktop_client *dclient = wl_resource_get_user_data(resource);
+
+ wl_list_remove(&dclient->link);
+ free(dclient);
+}
+
+static void
+bind_agl_shell_desktop(struct wl_client *client,
+ void *data, uint32_t version, uint32_t id)
+{
+ struct ivi_compositor *ivi = data;
+ struct wl_resource *resource;
+ struct desktop_client *dclient = zalloc(sizeof(*dclient));
+
+ if (!dclient) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ resource = wl_resource_create(client, &agl_shell_desktop_interface,
+ version, id);
+ if (!resource) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+
+ wl_resource_set_implementation(resource, &agl_shell_desktop_implementation,
+ dclient, unbind_agl_shell_desktop);
+
+ dclient->resource = resource;
+ wl_list_insert(&ivi->desktop_clients, &dclient->link);
+
+ /* advertise xdg surfaces */
+ ivi_shell_advertise_xdg_surfaces(ivi, resource);
+}
+