desktop: Install a black background for REMOTE roles
[src/agl-compositor.git] / src / desktop.c
index b2907fe..36fe6f2 100644 (file)
@@ -128,7 +128,8 @@ desktop_surface_added_configure(struct ivi_surface *surface,
 
        ivi_check_pending_surface_desktop(surface, &role);
        if ((role != IVI_SURFACE_ROLE_DESKTOP &&
-            role != IVI_SURFACE_ROLE_FULLSCREEN) ||
+            role != IVI_SURFACE_ROLE_FULLSCREEN &&
+            role != IVI_SURFACE_ROLE_REMOTE) ||
             role == IVI_SURFACE_ROLE_NONE)
                return;
 
@@ -164,6 +165,14 @@ desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
        dclient = weston_desktop_surface_get_client(dsurface);
        client = weston_desktop_client_get_client(dclient);
 
+       if (ivi->shell_client.resource &&
+           ivi->shell_client.status == BOUND_FAILED) {
+               wl_client_post_implementation_error(client,
+                                      "agl_shell has already been bound. "
+                                      "Check out bound_fail event");
+               return;
+       }
+
        surface = zalloc(sizeof *surface);
        if (!surface) {
                wl_client_post_no_memory(client);
@@ -250,10 +259,20 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata)
        struct weston_surface *wsurface =
                weston_desktop_surface_get_surface(dsurface);
        const char *app_id = NULL;
-       struct weston_seat *wseat = get_ivi_shell_weston_first_seat(surface->ivi);
-       struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
+       struct weston_seat *wseat = NULL;
+       struct ivi_shell_seat *ivi_seat = NULL;
+       struct ivi_output *output = NULL;
+
+       /* we might not have a valid ivi_surface if _added failed due to
+        * protocol errors */
+       if (!surface)
+               return;
+
+       wseat = get_ivi_shell_weston_first_seat(surface->ivi);
+       if (wseat)
+               ivi_seat = get_ivi_shell_seat(wseat);
 
-       struct ivi_output *output = ivi_layout_get_output_from_surface(surface);
+       output = ivi_layout_get_output_from_surface(surface);
 
        wl_list_remove(&surface->listener_advertise_app.link);
        surface->listener_advertise_app.notify = NULL;
@@ -305,10 +324,8 @@ desktop_surface_removed(struct weston_desktop_surface *dsurface, void *userdata)
        /* check if there's a last 'remote' surface and insert a black
         * surface view if there's no background set for that output
         */
-       if ((desktop_surface_check_last_remote_surfaces(output->ivi,
-               IVI_SURFACE_ROLE_REMOTE) ||
-           desktop_surface_check_last_remote_surfaces(output->ivi,
-               IVI_SURFACE_ROLE_DESKTOP)) && output->type == OUTPUT_REMOTE)
+       if (desktop_surface_check_last_remote_surfaces(output->ivi, IVI_SURFACE_ROLE_REMOTE) ||
+            desktop_surface_check_last_remote_surfaces(output->ivi, IVI_SURFACE_ROLE_DESKTOP))
                if (!output->background)
                        insert_black_surface(output);