compositor: Added layout_save/layout_restore
[src/agl-compositor.git] / src / layout.c
index 96eb215..028ff4a 100644 (file)
@@ -248,9 +248,11 @@ ivi_layout_activate_complete(struct ivi_output *output,
 
 
        weston_view_set_output(view, woutput);
-       weston_view_set_position(view,
-                                woutput->x + output->area.x,
-                                woutput->y + output->area.y);
+
+       if (surf->role != IVI_SURFACE_ROLE_BACKGROUND)
+               weston_view_set_position(view,
+                                        woutput->x + output->area.x,
+                                        woutput->y + output->area.y);
 
        view->is_mapped = true;
        surf->mapped = true;
@@ -275,12 +277,14 @@ ivi_layout_activate_complete(struct ivi_output *output,
                }
        }
 
-
        if (output->active) {
-               output->active->view->is_mapped = false;
-               output->active->view->surface->is_mapped = false;
+               /* keep the background surface mapped at all times */
+               if (output->active->role != IVI_SURFACE_ROLE_BACKGROUND) {
+                       output->active->view->is_mapped = false;
+                       output->active->view->surface->is_mapped = false;
 
-               weston_layer_entry_remove(&output->active->view->layer_link);
+                       weston_layer_entry_remove(&output->active->view->layer_link);
+               }
        }
        output->previous_active = output->active;
        output->active = surf;
@@ -308,10 +312,26 @@ ivi_layout_activate_complete(struct ivi_output *output,
                        app_id,
                        ivi_layout_get_surface_role_name(surf), output->name);
 
-      if (wl_resource_get_version(ivi->shell_client.resource) >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-               agl_shell_send_app_state(ivi->shell_client.resource,
-                                        app_id, AGL_SHELL_APP_STATE_ACTIVATED);
+       shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_ACTIVATED);
+}
+
+static bool
+ivi_layout_find_output_with_app_id(const char *app_id, struct ivi_output *output)
+{
+       char *cur;
+       size_t app_id_len;
+
+       cur = output->app_ids;
+       app_id_len = strlen(app_id);
+
+       while ((cur = strstr(cur, app_id))) {
+               if ((cur[app_id_len] == ',' || cur[app_id_len] == '\0') &&
+                   (cur == output->app_ids || cur[-1] == ','))
+                       return true;
+               cur++;
+       }
 
+       return false;
 }
 
 struct ivi_output *
@@ -323,13 +343,12 @@ ivi_layout_find_with_app_id(const char *app_id, struct ivi_compositor *ivi)
                return NULL;
 
        wl_list_for_each(out, &ivi->outputs, link) {
-               if (!out->app_id)
+               if (!out->app_ids)
                        continue;
 
-               if (!strcmp(app_id, out->app_id))
+               if (ivi_layout_find_output_with_app_id(app_id, out))
                        return out;
        }
-
        return NULL;
 }
 
@@ -923,6 +942,9 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
                struct ivi_output *remote_output =
                        ivi_layout_find_with_app_id(app_id, ivi);
 
+               weston_log("Changed activation for app_id %s, type %s, on output %s\n", app_id,
+                               ivi_layout_get_surface_role_name(surf), output->output->name);
+
                /* if already active on a remote output do not
                 * attempt to activate it again */
                if (remote_output && remote_output->active == surf)
@@ -941,6 +963,13 @@ ivi_layout_activate_by_surf(struct ivi_output *output, struct ivi_surface *surf)
                return;
        }
 
+       /* the background surface is already "maximized" so we don't need to
+        * add to the hidden layer */
+       if (surf->role == IVI_SURFACE_ROLE_BACKGROUND) {
+               ivi_layout_activate_complete(output, surf);
+               return;
+       }
+
        ivi_layout_add_to_hidden_layer(surf, output);
 }
 
@@ -1061,7 +1090,5 @@ ivi_layout_deactivate(struct ivi_compositor *ivi, const char *app_id)
                weston_surface_damage(view->surface);
        }
 
-      if (wl_resource_get_version(ivi->shell_client.resource) >= AGL_SHELL_APP_STATE_SINCE_VERSION)
-             agl_shell_send_app_state(ivi->shell_client.resource, app_id,
-                                      AGL_SHELL_APP_STATE_DEACTIVATED);
+      shell_send_app_state(ivi, app_id, AGL_SHELL_APP_STATE_DEACTIVATED);
 }