layout: Add a fallback for reading activation-area
[src/agl-compositor.git] / src / layout.c
index 1773fc8..ff5b55f 100644 (file)
@@ -30,6 +30,7 @@
 #include <assert.h>
 #include <string.h>
 
+#include <libweston/config-parser.h>
 #include <libweston/libweston.h>
 #include <libweston-desktop/libweston-desktop.h>
 
@@ -152,6 +153,23 @@ void
 ivi_layout_init(struct ivi_compositor *ivi, struct ivi_output *output)
 {
        bool use_default_area = true;
+       struct weston_config_section *section = output->config;
+       char *t;
+
+       weston_config_section_get_string(section, "activation-area", &t, NULL);
+       if (t) {
+               if (output->area_activation.width == 0 &&
+                   output->area_activation.height == 0 &&
+                   output->area_activation.x == 0 &&
+                   output->area_activation.y == 0) {
+                       weston_log("WARNING: activation-area set in "
+                                       "configuration file, but yet applied!\n");
+                       if (parse_activation_area(t, output) < 0)
+                               weston_log("Invalid activation-area \"%s\" for output %s\n",
+                                          t, output->name);
+               }
+       }
+       free(t);
 
        ivi_background_init(ivi, output);
 
@@ -312,10 +330,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 *
@@ -327,13 +361,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;
 }
 
@@ -394,8 +427,10 @@ ivi_layout_add_to_hidden_layer(struct ivi_surface *surf,
        if (surf->hidden_layer_output &&
            surf->hidden_layer_output != ivi_output) {
                weston_layer_entry_remove(&ev->layer_link);
+               weston_view_geometry_dirty(ev);
+               weston_surface_damage(ev->surface);
 
-               if (ivi_output->area.width != surf->hidden_layer_output->area.width &&
+               if (ivi_output->area.width != surf->hidden_layer_output->area.width ||
                    ivi_output->area.height != surf->hidden_layer_output->area.height) {
                        weston_desktop_surface_set_maximized(dsurf, true);
                        weston_desktop_surface_set_size(dsurf,
@@ -927,6 +962,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)
@@ -1072,7 +1110,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);
 }