From 3950b7e787c19bd1917533081c8fb8d4331e4ef3 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 15 Jan 2020 17:08:54 +0200 Subject: [PATCH] layout: Use the background's surface ivi_output when activating apps by default In order to activate application by default, we need a ivi_output which for the desktop role that's not available at that time (the activation part actually will set-up one). Uses the bg output for this case. This is only activated by adding 'activate-by-default' bool variable under the '[shell]' section (in the ini configuration file). Bug-AGL: SPEC-3118 Signed-off-by: Marius Vlad Change-Id: Ib44f0fcccc145216fb28fc9c26e5a065912ceef5 --- src/ivi-compositor.h | 4 ++++ src/layout.c | 35 ++++++++++++++++++++++++++++++++++- src/main.c | 16 ++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h index 68cbbdf..f3a51d6 100644 --- a/src/ivi-compositor.h +++ b/src/ivi-compositor.h @@ -62,6 +62,10 @@ struct ivi_compositor { const struct weston_drm_output_api *drm_api; struct wl_global *agl_shell; + struct { + int activate_apps_by_default; /* switches once xdg top level has been 'created' */ + } quirks; + struct { struct wl_client *client; struct wl_resource *resource; diff --git a/src/layout.c b/src/layout.c index 030e8b4..106f6fb 100644 --- a/src/layout.c +++ b/src/layout.c @@ -196,6 +196,20 @@ ivi_layout_activate_complete(struct ivi_output *output, surf->desktop.pending_output = NULL; } +static struct ivi_output * +ivi_layout_find_bg_output(struct ivi_compositor *ivi) +{ + struct ivi_output *out; + + wl_list_for_each(out, &ivi->outputs, link) { + if (out->background && + out->background->role == IVI_SURFACE_ROLE_BACKGROUND) + return out; + } + + return NULL; +} + void ivi_layout_desktop_committed(struct ivi_surface *surf) { @@ -206,8 +220,27 @@ ivi_layout_desktop_committed(struct ivi_surface *surf) assert(surf->role == IVI_SURFACE_ROLE_DESKTOP); output = surf->desktop.pending_output; - if (!output) + if (!output) { + struct ivi_output *ivi_bg_output; + + /* FIXME: This should be changed to determine if the policy + * database allows that to happen */ + if (!surf->ivi->quirks.activate_apps_by_default) + return; + + ivi_bg_output = ivi_layout_find_bg_output(surf->ivi); + + /* use the output of the bg to activate the app on start-up by + * default */ + if (surf->view && ivi_bg_output) { + const char *app_id = + weston_desktop_surface_get_app_id(dsurf); + if (app_id && ivi_bg_output) + ivi_layout_activate(ivi_bg_output, app_id); + } + return; + } if (!weston_desktop_surface_get_maximized(dsurf) || geom.width != output->area.width || diff --git a/src/main.c b/src/main.c index eefdc19..240fb77 100644 --- a/src/main.c +++ b/src/main.c @@ -1088,6 +1088,20 @@ usage(int error_code) exit(error_code); } +static void +ivi_compositor_get_quirks(struct ivi_compositor *ivi) +{ + struct weston_config_section *section; + + if (!ivi->config) + return; + + section = weston_config_get_section(ivi->config, "shell", NULL, NULL); + weston_config_section_get_bool(section, "activate-by-default", + &ivi->quirks.activate_apps_by_default, 0); + +} + int main(int argc, char *argv[]) { struct ivi_compositor ivi = { 0 }; @@ -1146,6 +1160,8 @@ int main(int argc, char *argv[]) backend = choose_default_backend(); } + ivi_compositor_get_quirks(&ivi); + display = wl_display_create(); loop = wl_display_get_event_loop(display); -- 2.16.6