Add manual activation area configuration option 52/28052/2
authorScott Murray <scott.murray@konsulko.com>
Tue, 11 Oct 2022 20:46:26 +0000 (16:46 -0400)
committerMarius Vlad <marius.vlad@collabora.com>
Wed, 12 Oct 2022 14:36:26 +0000 (14:36 +0000)
Add a per-output "activation-area" configuration option that can be
used to define the activation area for applications that are not
using panels.

Notes:
- A new surface is not created for the given activation area, so
  apps that are not opaque will show the background.  After some
  thought, this seems like acceptable behavior, but it is possible
  that I am missing something.
- At present setting the activation area explicitly disables use of
  any panels, this may not need to be the case and some discussion
  with the AGL community with respect to requirements is likely
  needed.
- It is likely that this feature should be done via a agl-shell
  protocol call instead of via configuration, but doing so will
  require some thought as to the interaction with panels and how
  configuration errors would be communicated back to a client.

Bug-AGL: SPEC-4588

Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I6cdae659f5f7636dc94121a69666b905abda3be3

src/compositor.c
src/ivi-compositor.h
src/layout.c

index 564153b..634c468 100644 (file)
@@ -327,6 +327,23 @@ parse_transform(const char *transform, uint32_t *out)
        return -1;
 }
 
+static int
+parse_activation_area(const char *geometry, struct ivi_output *output)
+{
+       int n;
+       unsigned width, height, x, y;
+
+       n = sscanf(geometry, "%ux%u+%u,%u", &width, &height, &x, &y);
+       if (n != 4) {
+               return -1;
+       }
+       output->area_activation.width = width;
+       output->area_activation.height = height;
+       output->area_activation.x = x;
+       output->area_activation.y = y;
+       return 0;
+}
+
 static int
 configure_output(struct ivi_output *output)
 {
@@ -350,6 +367,10 @@ configure_output(struct ivi_output *output)
                if (parse_transform(t, &transform) < 0)
                        weston_log("Invalid transform \"%s\" for output %s\n",
                                   t, output->name);
+               weston_config_section_get_string(section, "activation-area", &t, "");
+               if (parse_activation_area(t, output) < 0)
+                       weston_log("Invalid activation-area \"%s\" for output %s\n",
+                                  t, output->name);
                free(t);
        }
 
index 3cca0a0..bf96fc7 100644 (file)
@@ -155,6 +155,10 @@ struct ivi_output {
         */
        struct weston_geometry area;
        struct weston_geometry area_saved;
+       /*
+        * Potential user-specified non-default activation area
+        */
+       struct weston_geometry area_activation;
 
        struct ivi_surface *active;
        struct ivi_surface *previous_active;
index 25221e2..96eb215 100644 (file)
@@ -151,17 +151,40 @@ ivi_panel_init(struct ivi_compositor *ivi, struct ivi_output *output,
 void
 ivi_layout_init(struct ivi_compositor *ivi, struct ivi_output *output)
 {
-       ivi_background_init(ivi, output);
+       bool use_default_area = true;
 
-       output->area.x = 0;
-       output->area.y = 0;
-       output->area.width = output->output->width;
-       output->area.height = output->output->height;
+       ivi_background_init(ivi, output);
 
-       ivi_panel_init(ivi, output, output->top);
-       ivi_panel_init(ivi, output, output->bottom);
-       ivi_panel_init(ivi, output, output->left);
-       ivi_panel_init(ivi, output, output->right);
+       if (output->area_activation.width ||
+           output->area_activation.height ||
+           output->area_activation.x ||
+           output->area_activation.y) {
+               /* Sanity check target area is within output bounds */
+               if ((output->area_activation.x + output->area_activation.width) < output->output->width ||
+                   (output->area_activation.y + output->area_activation.height) < output->output->height) {
+                       weston_log("Using specified area for output %s, ignoring panels\n",
+                                  output->name);
+                       output->area.x = output->area_activation.x;
+                       output->area.y = output->area_activation.y;
+                       output->area.width = output->area_activation.width;
+                       output->area.height = output->area_activation.height;
+                       use_default_area = false;
+               } else {
+                       weston_log("Invalid activation-area position for output %s, ignoring\n",
+                                  output->name);
+               }
+       }
+       if (use_default_area) {
+               output->area.x = 0;
+               output->area.y = 0;
+               output->area.width = output->output->width;
+               output->area.height = output->output->height;
+
+               ivi_panel_init(ivi, output, output->top);
+               ivi_panel_init(ivi, output, output->bottom);
+               ivi_panel_init(ivi, output, output->left);
+               ivi_panel_init(ivi, output, output->right);
+       }
 
        weston_compositor_schedule_repaint(ivi->compositor);
 
@@ -349,8 +372,8 @@ ivi_layout_add_to_hidden_layer(struct ivi_surface *surf,
                                                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);
+                          app_id, ivi_layout_get_surface_role_name(surf),
+                          ivi_output->area.width, ivi_output->area.height);
 
                surf->hidden_layer_output = ivi_output;
                weston_view_set_output(ev, ivi_output->output);