From c198364a7d129a6df7e62e0c2773151a7c355c6c Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 15 Oct 2020 12:43:00 +0800 Subject: [PATCH 36/95] compositor: Support setting default layer for the first app Set env "WESTON_FIRST_APP_LAYER" to "top" or "bottom". Signed-off-by: Jeffy Chen --- include/libweston/libweston.h | 3 +++ libweston/compositor.c | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index 573accf..a286c21 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -1992,6 +1992,9 @@ enum weston_surface_flags { SURFACE_ACTIVATE = 1 << 5, }; +#define WESTON_SURFACE_FLAGS_STAY_MASK \ + ((uint32_t)(SURFACE_STAY_ON_TOP | SURFACE_STAY_ON_BOTTOM)) + struct weston_surface { struct wl_resource *resource; struct wl_signal destroy_signal; /* callback argument: this surface */ diff --git a/libweston/compositor.c b/libweston/compositor.c index 7870f9a..e850a95 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -3706,14 +3706,30 @@ weston_compositor_build_view_list(struct weston_compositor *compositor) wl_list_for_each(layer, &compositor->layer_list, link) { bool system_layer = weston_compositor_is_system_layer(layer); + static bool seen_first = false; if (compositor->hide_cursor && layer == &compositor->cursor_layer) continue; wl_list_for_each(view, &layer->view_list.link, layer_link.link) { - if (compositor->warm_up && !system_layer) { + if (!seen_first && !system_layer) { + const char *env; + weston_log("seeing the first app\n"); + seen_first = true; + compositor->warm_up = false; + + if (!(view->surface->flags & + WESTON_SURFACE_FLAGS_STAY_MASK)) { + env = getenv("WESTON_FIRST_APP_LAYER"); + if (env && !strcmp(env, "top")) + view->surface->flags |= + SURFACE_STAY_ON_TOP; + else if (env && !strcmp(env, "bottom")) + view->surface->flags |= + SURFACE_STAY_ON_BOTTOM; + } } view_list_add(compositor, view); -- 2.20.1