layout: State explicity the output
[src/agl-compositor.git] / src / layout.c
index dd4abb5..86b4b7f 100644 (file)
@@ -275,6 +275,41 @@ ivi_layout_find_bg_output(struct ivi_compositor *ivi)
        return NULL;
 }
 
+
+static void
+ivi_layout_add_to_hidden_layer(struct ivi_surface *surf,
+                              struct ivi_output *ivi_output)
+{
+       struct weston_desktop_surface *dsurf = surf->dsurface;
+       struct weston_view *ev = surf->view;
+       struct ivi_compositor *ivi = surf->ivi;
+       const char *app_id = weston_desktop_surface_get_app_id(dsurf);
+
+       /*
+        * If the view isn't mapped, we put it onto the hidden layer so it will
+        * start receiving frame events, and will be able to act on our
+        * configure event.
+        */
+       if (!weston_view_is_mapped(ev)) {
+               ev->is_mapped = true;
+               ev->surface->is_mapped = true;
+
+               weston_desktop_surface_set_maximized(dsurf, true);
+               weston_desktop_surface_set_size(dsurf,
+                                               ivi_output->area.width,
+                                               ivi_output->area.height);
+
+               weston_log("Setting app_id %s, role %s, set to maximized (%dx%d)\n",
+                               app_id, ivi_layout_get_surface_role_name(surf),
+                               ivi_output->area.width, ivi_output->area.height);
+
+               weston_view_set_output(ev, ivi_output->output);
+               weston_layer_entry_insert(&ivi->hidden.view_list, &ev->layer_link);
+               weston_log("Placed app_id %s, type %s in hidden layer\n",
+                               app_id, ivi_layout_get_surface_role_name(surf));
+       }
+}
+
 void
 ivi_layout_desktop_committed(struct ivi_surface *surf)
 {
@@ -336,6 +371,12 @@ ivi_layout_desktop_committed(struct ivi_surface *surf)
                if (!surf->ivi->activate_by_default) {
                        weston_log("Refusing to activate surface role %d, app_id %s\n",
                                        surf->role, app_id);
+
+                       if (!weston_desktop_surface_get_maximized(dsurf) ||
+                           geom.width != r_output->area.width ||
+                           geom.height != r_output->area.height)
+                               ivi_layout_add_to_hidden_layer(surf, r_output);
+
                        return;
                }
 
@@ -378,9 +419,11 @@ ivi_layout_desktop_committed(struct ivi_surface *surf)
                        return;
 
                if (app_id) {
-                       weston_log("Surface with app_id %s, role %s activating by default\n",
-                                       weston_desktop_surface_get_app_id(surf->dsurface),
-                                       ivi_layout_get_surface_role_name(surf));
+                       weston_log("Surface with app_id %s, role %s activating "
+                                  "by default on output %s\n",
+                                  weston_desktop_surface_get_app_id(surf->dsurface),
+                                  ivi_layout_get_surface_role_name(surf),
+                                  output->output->name);
                        ivi_layout_activate(output, app_id);
                }
                return;
@@ -648,7 +691,7 @@ ivi_layout_popup_committed(struct ivi_surface *surface)
            !surface->mapped)
                return;
 
-       if (surface->view->is_mapped)
+       if (surface->view->is_mapped || surface->state == HIDDEN)
                return;
 
        assert(surface->role == IVI_SURFACE_ROLE_POPUP);
@@ -658,6 +701,7 @@ ivi_layout_popup_committed(struct ivi_surface *surface)
        ivi_compute_popup_position(woutput, view,
                                   surface->popup.x, surface->popup.y, &new_x, &new_y);
        weston_view_set_position(view, new_x, new_y);
+       weston_view_update_transform(view);
 
        /* only clip the pop-up dialog window if we have a valid
         * width and height being passed on. Users might not want to have one
@@ -706,6 +750,7 @@ ivi_layout_popup_re_add(struct ivi_surface *surface)
        if (!surface->mapped)
                surface->mapped = true;
 
+       surface->state = NORMAL;
        ivi_layout_popup_committed(surface);
 }
 
@@ -737,12 +782,10 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
 {
        struct ivi_compositor *ivi = output->ivi;
        struct weston_desktop_surface *dsurf;
-       struct weston_view *view;
        struct weston_geometry geom;
        struct ivi_policy *policy = output->ivi->policy;
 
        dsurf = surf->dsurface;
-       view = surf->view;
 
        const char *app_id = weston_desktop_surface_get_app_id(dsurf);
 
@@ -755,8 +798,8 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
        }
 
 #ifdef AGL_COMP_DEBUG
-       weston_log("Activating app_id %s, type %s\n", app_id,
-                       ivi_layout_get_surface_role_name(surf));
+       weston_log("Activating app_id %s, type %s, on output %s\n", app_id,
+                       ivi_layout_get_surface_role_name(surf), output->output->name);
 #endif
 
        if (surf->role == IVI_SURFACE_ROLE_POPUP) {
@@ -791,28 +834,7 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
                return;
        }
 
-       weston_desktop_surface_set_maximized(dsurf, true);
-       weston_desktop_surface_set_size(dsurf,
-                                       output->area.width,
-                                       output->area.height);
-
-       weston_log("Setting app_id %s, role %s, set to maximized (%dx%d)\n",
-                       app_id, ivi_layout_get_surface_role_name(surf),
-                       output->area.width, output->area.height);
-       /*
-        * If the view isn't mapped, we put it onto the hidden layer so it will
-        * start receiving frame events, and will be able to act on our
-        * configure event.
-        */
-       if (!weston_view_is_mapped(view)) {
-               view->is_mapped = true;
-               view->surface->is_mapped = true;
-
-               weston_view_set_output(view, output->output);
-               weston_layer_entry_insert(&ivi->hidden.view_list, &view->layer_link);
-               weston_log("Placed app_id %s, type %s in hidden layer\n",
-                               app_id, ivi_layout_get_surface_role_name(surf));
-       }
+       ivi_layout_add_to_hidden_layer(surf, output);
 }
 
 void
@@ -924,6 +946,9 @@ ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
        } else if (surf->role == IVI_SURFACE_ROLE_POPUP) {
                struct weston_view *view  = surf->view;
 
+               weston_view_unmap(view);
+               surf->state = HIDDEN;
+
                weston_layer_entry_remove(&view->layer_link);
                weston_view_geometry_dirty(view);
                weston_surface_damage(view->surface);