+static void
+ivi_set_desktop_surface_remote(struct ivi_surface *surface)
+{
+ struct ivi_compositor *ivi = surface->ivi;
+ struct weston_view *view;
+ struct ivi_output *output = surface->remote.output;
+
+ assert(surface->role == IVI_SURFACE_ROLE_NONE);
+
+ /* remote type are the same as desktop just that client can tell
+ * the compositor to start on another output */
+ surface->role = IVI_SURFACE_ROLE_REMOTE;
+
+ /* if thew black surface view is mapped on the mean we need
+ * to remove it in order to start showing the 'remote' surface
+ * just being added */
+ view = output->fullscreen_view.fs->view;
+ if (view->is_mapped || view->surface->is_mapped)
+ remove_black_surface(output);
+
+ if (output->type == OUTPUT_WALTHAM)
+ ivi_output_notify_waltham_plugin(surface);
+
+ wl_list_insert(&ivi->surfaces, &surface->link);
+}
+
+
+static void
+ivi_set_desktop_surface_split(struct ivi_surface *surface)
+{
+ struct ivi_compositor *ivi = surface->ivi;
+ assert(surface->role == IVI_SURFACE_ROLE_NONE);
+
+ if (surface->split.orientation == AGL_SHELL_DESKTOP_APP_ROLE_SPLIT_VERTICAL)
+ surface->role = IVI_SURFACE_ROLE_SPLIT_V;
+ else
+ surface->role = IVI_SURFACE_ROLE_SPLIT_H;
+
+ wl_list_insert(&ivi->surfaces, &surface->link);
+
+ agl_shell_desktop_advertise_application_id(ivi, surface);
+}
+
+static struct pending_popup *
+ivi_ensure_popup(struct ivi_output *ioutput, int x, int y, int bx, int by,
+ int width, int height, const char *app_id)
+{
+ struct pending_popup *p_popup = zalloc(sizeof(*p_popup));
+ size_t len_app_id = strlen(app_id);
+
+ if (!p_popup)
+ return NULL;
+ p_popup->app_id = zalloc(sizeof(char) * (len_app_id + 1));
+ if (!p_popup->app_id) {
+ free(p_popup);
+ return NULL;
+ }
+ memcpy(p_popup->app_id, app_id, len_app_id);
+ p_popup->ioutput = ioutput;
+ p_popup->x = x;
+ p_popup->y = y;
+
+ p_popup->bb.x = bx;
+ p_popup->bb.y = by;
+ p_popup->bb.width = width;
+ p_popup->bb.height = height;
+
+ return p_popup;
+}
+
+static void
+ivi_update_popup(struct ivi_output *ioutput, int x, int y, int bx, int by,
+ int width, int height, const char *app_id, struct pending_popup *p_popup)
+{
+ size_t len_app_id = strlen(app_id);
+
+ wl_list_remove(&p_popup->link);
+ wl_list_init(&p_popup->link);
+
+ memset(p_popup->app_id, 0, strlen(app_id) + 1);
+ free(p_popup->app_id);
+
+ p_popup->app_id = zalloc(sizeof(char) * (len_app_id + 1));
+ if (!p_popup->app_id)
+ return;
+ memcpy(p_popup->app_id, app_id, len_app_id);
+
+ p_popup->ioutput = ioutput;
+ p_popup->x = x;
+ p_popup->y = y;
+
+ p_popup->bb.x = bx;
+ p_popup->bb.y = by;
+ p_popup->bb.width = width;
+ p_popup->bb.height = height;
+}
+
+static struct pending_fullscreen *
+ivi_ensure_fullscreen(struct ivi_output *ioutput, const char *app_id)
+{
+ struct pending_fullscreen *p_fullscreen = zalloc(sizeof(*p_fullscreen));
+ size_t len_app_id = strlen(app_id);
+
+ if (!p_fullscreen)
+ return NULL;
+ p_fullscreen->app_id = zalloc(sizeof(char) * (len_app_id + 1));
+ if (!p_fullscreen->app_id) {
+ free(p_fullscreen);
+ return NULL;
+ }
+ memcpy(p_fullscreen->app_id, app_id, len_app_id);
+
+ p_fullscreen->ioutput = ioutput;
+ return p_fullscreen;
+}
+
+static void
+ivi_update_fullscreen(struct ivi_output *ioutput, const char *app_id,
+ struct pending_fullscreen *p_fullscreen)
+{
+ size_t len_app_id = strlen(app_id);
+
+ wl_list_remove(&p_fullscreen->link);
+ wl_list_init(&p_fullscreen->link);
+
+ memset(p_fullscreen->app_id, 0, strlen(app_id) + 1);
+ free(p_fullscreen->app_id);
+
+ p_fullscreen->app_id = zalloc(sizeof(char) * (len_app_id + 1));
+ if (!p_fullscreen->app_id)
+ return;
+ memcpy(p_fullscreen->app_id, app_id, len_app_id);
+
+ p_fullscreen->ioutput = ioutput;
+}
+
+static struct pending_remote *
+ivi_ensure_remote(struct ivi_output *ioutput, const char *app_id)