From f676a8f54ef66efeeb2c78f96eceb6ea4d6253cc Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 9 Nov 2021 19:25:46 +0200 Subject: [PATCH] kiosk-shell: Add a border fill to non-fullscreen views According to xdg-shell spec, if the surface doesn't cover the whole output we should center it and install a border fill covering the rest of the output. While we center out the surface we never got around installing the border fill. This patch re-uses the activation of a surface to control this bit as well, by making use of an new layer to place the surface while not being active. Signed-off-by: Marius Vlad --- kiosk-shell/kiosk-shell.c | 27 ++++++++++++++++++++++++--- kiosk-shell/kiosk-shell.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 709e37de..45e83536 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -384,12 +384,31 @@ kiosk_shell_surface_activate(struct kiosk_shell_surface *shsurf, dsurface_focus = current_focus->desktop_surface; if (--current_focus->focus_count == 0) weston_desktop_surface_set_activated(dsurface_focus, false); + + /* removes it from the normal_layer and move it to inactive + * one, without occluding the top-level window if the new one + * is a child to that */ + if (!shsurf->parent) { + weston_layer_entry_remove(¤t_focus->view->layer_link); + weston_layer_entry_insert(&shsurf->shell->inactive_layer.view_list, + ¤t_focus->view->layer_link); + weston_view_geometry_dirty(current_focus->view); + weston_surface_damage(current_focus->view->surface); + } } /* xdg-shell activation for the new one */ kiosk_seat->focused_surface = surface; if (shsurf->focus_count++ == 0) weston_desktop_surface_set_activated(dsurface, true); + + /* removes it from the inactive_layer, on removal of a surface, and + * move it back to the normal layer */ + weston_layer_entry_remove(&shsurf->view->layer_link); + weston_layer_entry_insert(&shsurf->shell->normal_layer.view_list, + &shsurf->view->layer_link); + weston_view_geometry_dirty(shsurf->view); + weston_surface_damage(shsurf->view->surface); } /* @@ -676,7 +695,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface, kiosk_seat = get_kiosk_shell_seat(seat); if (seat && kiosk_seat) { - focus_view = find_focus_successor(&shell->normal_layer, shsurf, + focus_view = find_focus_successor(&shell->inactive_layer, shsurf, kiosk_seat->focused_surface); if (focus_view) { @@ -740,8 +759,6 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, get_kiosk_shell_first_seat(shsurf->shell); struct kiosk_shell_seat *kiosk_seat; - weston_layer_entry_insert(&shsurf->shell->normal_layer.view_list, - &shsurf->view->layer_link); shsurf->view->is_mapped = true; surface->is_mapped = true; @@ -1105,6 +1122,7 @@ kiosk_shell_destroy(struct wl_listener *listener, void *data) weston_layer_fini(&shell->background_layer); weston_layer_fini(&shell->normal_layer); + weston_layer_fini(&shell->inactive_layer); free(shell); } @@ -1139,9 +1157,12 @@ wet_shell_init(struct weston_compositor *ec, weston_layer_init(&shell->background_layer, ec); weston_layer_init(&shell->normal_layer, ec); + weston_layer_init(&shell->inactive_layer, ec); weston_layer_set_position(&shell->background_layer, WESTON_LAYER_POSITION_BACKGROUND); + weston_layer_set_position(&shell->inactive_layer, + WESTON_LAYER_POSITION_HIDDEN); /* We use the NORMAL layer position, so that xwayland surfaces, which * are placed at NORMAL+1, are visible. */ weston_layer_set_position(&shell->normal_layer, diff --git a/kiosk-shell/kiosk-shell.h b/kiosk-shell/kiosk-shell.h index 56325dbb..9f680806 100644 --- a/kiosk-shell/kiosk-shell.h +++ b/kiosk-shell/kiosk-shell.h @@ -41,6 +41,7 @@ struct kiosk_shell { struct weston_layer background_layer; struct weston_layer normal_layer; + struct weston_layer inactive_layer; struct wl_list output_list; struct wl_list seat_list;