src: Don't attempt to split background role window
[src/agl-compositor.git] / src / layout.c
index c11dacb..95d3e54 100644 (file)
@@ -48,6 +48,7 @@ static const char *ivi_roles_as_string[] = {
        [IVI_SURFACE_ROLE_SPLIT_V]      = "SPLIT_V",
        [IVI_SURFACE_ROLE_FULLSCREEN]   = "FULLSCREEN",
        [IVI_SURFACE_ROLE_REMOTE]       = "REMOTE",
+       [IVI_SURFACE_ROLE_TILE]         = "SPLIT",
 };
 
 bool
@@ -284,6 +285,13 @@ ivi_layout_activate_complete(struct ivi_output *output,
                                         woutput->x + output->area.x,
                                         woutput->y + output->area.y);
 
+       /* reset any previous orientation */
+       if (surf->orientation != AGL_SHELL_TILE_ORIENTATION_NONE) {
+               weston_log("%s() resetting itself to none orientation\n", __func__);
+               surf->orientation = AGL_SHELL_TILE_ORIENTATION_NONE;
+               weston_desktop_surface_set_orientation(surf->dsurface,
+                                                      surf->orientation);
+       }
        view->is_mapped = true;
        surf->mapped = true;
        view->surface->is_mapped = true;
@@ -730,6 +738,7 @@ ivi_layout_fullscreen_committed(struct ivi_surface *surface)
                           ivi_layout_get_surface_role_name(surface),
                           output->name);
 
+               weston_compositor_schedule_repaint(ivi->compositor);
        }
 }
 
@@ -974,6 +983,32 @@ ivi_layout_popup_re_add(struct ivi_surface *surface)
        ivi_layout_popup_committed(surface);
 }
 
+static void
+ivi_layout_fullscreen_re_add(struct ivi_surface *surface)
+{
+       assert(surface->role == IVI_SURFACE_ROLE_FULLSCREEN);
+       struct weston_view *view = surface->view;
+
+       if (weston_view_is_mapped(view)) {
+               struct weston_desktop_surface *dsurface = surface->dsurface;
+               struct weston_surface *wsurface =
+                       weston_desktop_surface_get_surface(dsurface);
+
+               weston_layer_entry_remove(&view->layer_link);
+
+               wsurface->is_mapped = false;
+               view->is_mapped = false;
+       }
+
+       /* reset the activate by default in order to (still) allow the surface
+        * to be activaved using the request */
+       if (!surface->mapped)
+               surface->mapped = true;
+
+       surface->state = NORMAL;
+       ivi_layout_fullscreen_committed(surface);
+}
+
 static bool
 ivi_layout_surface_is_split_or_fullscreen(struct ivi_surface *surf)
 {
@@ -997,6 +1032,53 @@ ivi_layout_surface_is_split_or_fullscreen(struct ivi_surface *surf)
        return false;
 }
 
+void
+ivi_layout_reset_split_surfaces(struct ivi_compositor *ivi)
+{
+       struct ivi_surface *ivisurf;
+       bool found_split_surface = false;
+       struct ivi_output *output = NULL;
+
+       wl_list_for_each(ivisurf, &ivi->surfaces, link) {
+               if (ivisurf->orientation != AGL_SHELL_TILE_ORIENTATION_NONE) {
+                       found_split_surface = true;
+                       break;
+               }
+       }
+
+       if (!found_split_surface)
+               return;
+
+       output = ivisurf->current_completed_output;
+       if (output->previous_active && output->background != output->previous_active) {
+               struct weston_view *ev = output->previous_active->view;
+               struct weston_output *woutput = output->output;
+
+               if (!weston_view_is_mapped(ev))
+                       weston_view_update_transform(ev);
+               else
+                       weston_layer_entry_remove(&ev->layer_link);
+
+               ev->is_mapped = true;
+               ev->surface->is_mapped = true;
+               output->previous_active->mapped = true;
+
+               weston_view_set_output(ev, woutput);
+
+               weston_layer_entry_insert(&ivi->normal.view_list, &ev->layer_link);
+
+               _ivi_set_shell_surface_split(output->previous_active, NULL,
+                                            AGL_SHELL_TILE_ORIENTATION_NONE, false);
+
+               if (output->active == ivisurf) {
+                       output->active = output->previous_active;
+               }
+       }
+
+       _ivi_set_shell_surface_split(ivisurf, NULL,
+                                    AGL_SHELL_TILE_ORIENTATION_NONE, false);
+}
+
 void
 ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
 {
@@ -1027,14 +1109,34 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
                return;
        }
 
+       if (surf->role == IVI_SURFACE_ROLE_FULLSCREEN) {
+               ivi_layout_fullscreen_re_add(surf);
+               return;
+       }
+#if 0
+       /* reset tile to desktop to allow to resize correctly */
+       if (surf->role == IVI_SURFACE_ROLE_TILE && output->active == surf) {
+               weston_log("%s() resetting tile role!\n", __func__);
+               surf->role = IVI_SURFACE_ROLE_DESKTOP;
+       }
+#endif
+
        /* do not 're'-activate surfaces that are split or active */
-       if (surf == output->active ||
-           ivi_layout_surface_is_split_or_fullscreen(surf)) {
+       if (surf == output->active) {
                weston_log("Application %s is already active on output %s\n",
                                app_id, output->output->name);
                return;
        }
 
+       if (ivi_layout_surface_is_split_or_fullscreen(surf)) {
+               weston_log("Application %s is fullscreen or split on output %s\n",
+                               app_id, output->output->name);
+               return;
+       }
+
+       // destroy any split types to allow correct re-activation
+       ivi_layout_reset_split_surfaces(surf->ivi);
+
        if (surf->role == IVI_SURFACE_ROLE_REMOTE) {
                struct ivi_output *remote_output =
                        ivi_layout_find_with_app_id(app_id, ivi);
@@ -1117,8 +1219,13 @@ ivi_layout_get_output_from_surface(struct ivi_surface *surf)
        case IVI_SURFACE_ROLE_REMOTE:
                ivi_output = surf->remote.output;
                break;
+       case IVI_SURFACE_ROLE_TILE:
+               ivi_output = surf->current_completed_output;
+               break;
        case IVI_SURFACE_ROLE_NONE:
        default:
+               if (surf->view->output)
+                       return to_ivi_output(surf->view->output);
                break;
        }
 
@@ -1177,7 +1284,8 @@ ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
                                weston_desktop_surface_get_app_id(dsurface);
                        ivi_layout_activate(ivi_output, previous_active_app_id);
                }
-       } else if (surf->role == IVI_SURFACE_ROLE_POPUP) {
+       } else if (surf->role == IVI_SURFACE_ROLE_POPUP ||
+                  surf->role == IVI_SURFACE_ROLE_FULLSCREEN) {
                struct weston_view *view  = surf->view;
 
                weston_view_unmap(view);
@@ -1188,5 +1296,5 @@ ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
                weston_surface_damage(view->surface);
        }
 
-      shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_DEACTIVATED);
+       shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_DEACTIVATED);
 }