+static bool
+ivi_check_pending_desktop_surface_split(struct ivi_surface *surface)
+{
+ struct pending_split *split_surf, *next_split_surf;
+ struct ivi_compositor *ivi = surface->ivi;
+ const char *_app_id =
+ weston_desktop_surface_get_app_id(surface->dsurface);
+
+ if (wl_list_empty(&ivi->split_pending_apps) || !_app_id)
+ return false;
+
+ wl_list_for_each_safe(split_surf, next_split_surf,
+ &ivi->split_pending_apps, link) {
+ if (!strcmp(_app_id, split_surf->app_id)) {
+ surface->split.output = split_surf->ioutput;
+ surface->split.orientation = split_surf->orientation;
+ ivi_remove_pending_desktop_surface_split(split_surf);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool
+ivi_check_pending_desktop_surface_fullscreen(struct ivi_surface *surface)
+{
+ struct pending_fullscreen *fs_surf, *next_fs_surf;
+ struct ivi_compositor *ivi = surface->ivi;
+ const char *_app_id =
+ weston_desktop_surface_get_app_id(surface->dsurface);
+
+ if (wl_list_empty(&ivi->fullscreen_pending_apps) || !_app_id)
+ return false;
+
+ wl_list_for_each_safe(fs_surf, next_fs_surf,
+ &ivi->fullscreen_pending_apps, link) {
+ if (!strcmp(_app_id, fs_surf->app_id)) {
+ surface->fullscreen.output = fs_surf->ioutput;
+ ivi_remove_pending_desktop_surface_fullscreen(fs_surf);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool
+ivi_check_pending_desktop_surface_remote(struct ivi_surface *surface)
+{
+ struct pending_remote *remote_surf, *next_remote_surf;
+ struct ivi_compositor *ivi = surface->ivi;
+ const char *_app_id =
+ weston_desktop_surface_get_app_id(surface->dsurface);
+
+ if (wl_list_empty(&ivi->remote_pending_apps) || !_app_id)
+ return false;
+
+ wl_list_for_each_safe(remote_surf, next_remote_surf,
+ &ivi->remote_pending_apps, link) {
+ if (!strcmp(_app_id, remote_surf->app_id)) {
+ surface->remote.output = remote_surf->ioutput;
+ ivi_remove_pending_desktop_surface_remote(remote_surf);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+void
+ivi_check_pending_desktop_surface(struct ivi_surface *surface)
+{
+ bool ret = false;
+
+ ret = ivi_check_pending_desktop_surface_popup(surface);
+ if (ret) {
+ ivi_set_desktop_surface_popup(surface);
+ ivi_layout_popup_committed(surface);
+ return;
+ }
+
+ ret = ivi_check_pending_desktop_surface_split(surface);
+ if (ret) {
+ ivi_set_desktop_surface_split(surface);
+ ivi_layout_split_committed(surface);
+ return;
+ }
+
+ ret = ivi_check_pending_desktop_surface_fullscreen(surface);
+ if (ret) {
+ ivi_set_desktop_surface_fullscreen(surface);
+ ivi_layout_fullscreen_committed(surface);
+ return;
+ }
+
+ ret = ivi_check_pending_desktop_surface_remote(surface);
+ if (ret) {
+ ivi_set_desktop_surface_remote(surface);
+ ivi_layout_desktop_committed(surface);
+ return;
+ }
+
+ /* if we end up here means we have a regular desktop app and
+ * try to activate it */
+ ivi_set_desktop_surface(surface);
+ ivi_layout_desktop_committed(surface);
+}
+