From 1077a8ed9b715ed1d00c1553d69ce5b6c10d9e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20G=C3=B3mez?= Date: Fri, 26 May 2023 17:00:41 -0500 Subject: [PATCH] kiosk-shell: Introduce an "active surface tree" for each kiosk shell output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces to the kiosk shell output structure a pointer to a surface tree list. This pointer will reference the surface tree list currently active on the output. (Surface tree lists were introduced in the previous commit) Each output will have at most one active surface tree. A surface tree being active on an output means that all views for this output belonging to that surface tree, and only those views, are in the normal layer. kiosk_shell_output_set_active_surface_tree() sets the current active surface tree for the specified output, replacing the previous one. Set the new active surface tree when first mapping a surface Signed-off-by: Sergio Gómez --- kiosk-shell/kiosk-shell.c | 40 +++++++++++++++++++++++++++++++++++++++ kiosk-shell/kiosk-shell.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 23de7ff3a..476aca478 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -467,6 +467,35 @@ kiosk_shell_seat_create(struct kiosk_shell *shell, struct weston_seat *seat) * kiosk_shell_output */ +static void +kiosk_shell_output_set_active_surface_tree(struct kiosk_shell_output *shoutput, + struct kiosk_shell_surface *shroot) + +{ + struct kiosk_shell *shell = shoutput->shell; + struct kiosk_shell_surface *s; + + /* Remove the previous active surface tree (i.e., move the tree to + * WESTON_LAYER_POSITION_HIDDEN) */ + if (shoutput->active_surface_tree) { + wl_list_for_each_reverse(s, shoutput->active_surface_tree, surface_tree_link) { + weston_view_move_to_layer(s->view, + &shell->inactive_layer.view_list); + } + } + + if (shroot) { + wl_list_for_each_reverse(s, &shroot->surface_tree_list, surface_tree_link) { + weston_view_move_to_layer(s->view, + &shell->normal_layer.view_list); + } + } + + shoutput->active_surface_tree = shroot ? + &shroot->surface_tree_list : + NULL; +} + static int kiosk_shell_background_surface_get_label(struct weston_surface *surface, char *buf, size_t len) @@ -795,12 +824,23 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, if (!weston_surface_is_mapped(surface)) { struct weston_seat *seat = get_kiosk_shell_first_seat(shsurf->shell); + struct kiosk_shell_output *shoutput = + kiosk_shell_find_shell_output(shsurf->shell, + shsurf->output); struct kiosk_shell_seat *kiosk_seat; shsurf->view->is_mapped = true; weston_surface_map(surface); kiosk_seat = get_kiosk_shell_seat(seat); + + /* We are mapping a new surface tree root; set it active, + * replacing the previous one */ + if (!shsurf->parent) { + kiosk_shell_output_set_active_surface_tree(shoutput, + shsurf); + } + if (seat && kiosk_seat) kiosk_shell_surface_activate(shsurf, kiosk_seat, WESTON_ACTIVATE_FLAG_NONE); diff --git a/kiosk-shell/kiosk-shell.h b/kiosk-shell/kiosk-shell.h index e1eb68cd4..007c33abf 100644 --- a/kiosk-shell/kiosk-shell.h +++ b/kiosk-shell/kiosk-shell.h @@ -97,6 +97,8 @@ struct kiosk_shell_output { struct wl_list link; char *app_ids; + + struct wl_list *active_surface_tree; }; #endif /* WESTON_KIOSK_SHELL_H */