layout: Make the view mapped at activation completion
[src/agl-compositor.git] / src / desktop.c
index 9c1dfae..efebfc1 100644 (file)
@@ -134,7 +134,7 @@ desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
        surface->ivi = ivi;
        surface->dsurface = dsurface;
        surface->role = IVI_SURFACE_ROLE_NONE;
-       surface->activated_by_default = false;
+       surface->mapped = false;
        surface->advertised_on_launch = false;
        surface->checked_pending = false;
        wl_list_init(&surface->link);
@@ -169,11 +169,15 @@ desktop_surface_added(struct weston_desktop_surface *dsurface, void *userdata)
        if (output && ivi->shell_client.ready) {
                struct ivi_output *ivi_output = to_ivi_output(output);
 
-               weston_log("Setting surface to initial size of surface to %dx%d\n",
-                               ivi_output->area.width, ivi_output->area.height);
-               weston_desktop_surface_set_maximized(dsurface, true);
-               weston_desktop_surface_set_size(dsurface,
-                               ivi_output->area.width, ivi_output->area.height);
+               /* verify if by any chance this surfaces hasn't been assigned a
+                * different role before sending the maximized state */
+               if (!ivi_check_pending_surface(surface)) {
+                       weston_log("Setting surface to initial size of surface to %dx%d\n",
+                                       ivi_output->area.width, ivi_output->area.height);
+                       weston_desktop_surface_set_maximized(dsurface, true);
+                       weston_desktop_surface_set_size(dsurface,
+                                       ivi_output->area.width, ivi_output->area.height);
+               }
        }
        /*
         * We delay creating "normal" desktop surfaces until later, to
@@ -432,6 +436,17 @@ static const struct weston_desktop_api desktop_api = {
        .set_xwayland_position = desktop_set_xwayland_position,
 };
 
+static void
+ivi_shell_destroy(struct wl_listener *listener, void *data)
+{
+       struct ivi_compositor *ivi = container_of(listener,
+                               struct ivi_compositor, destroy_listener);
+
+       weston_desktop_destroy(ivi->desktop);
+       ivi_compositor_destroy_pending_surfaces(ivi);
+       wl_list_remove(&listener->link);
+}
+
 int
 ivi_desktop_init(struct ivi_compositor *ivi)
 {
@@ -441,5 +456,10 @@ ivi_desktop_init(struct ivi_compositor *ivi)
                return -1;
        }
 
+       if (!weston_compositor_add_destroy_listener_once(ivi->compositor,
+                       &ivi->destroy_listener, ivi_shell_destroy)) {
+               return -1;
+       }
+
        return 0;
 }