kiosk-shell: Distinguish between 'destroy_signal' and 'parent_destroy_signal'

Currently, the 'parent_destroy_listener' is being paired with
'destroy_signal'. The signal is emitted from kiosk_shell_surface_destroy(),
which is the appropriate place to emit this general-purpose surface destruction
signal.

However, we need to inform the children of the surface destruction before
finding the focus successor and activating it, that is, before calling
find_focus_successor() and kiosk_shell_surface_activate(), which happen before
kiosk_shell_surface_destroy().
Since there are currently other uses for 'destroy_signal' (e.g. in
kiosk-shell-grab.c), don't mess with it and simply add a new
'parent_destroy_signal', placing its emition where we need it.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
This commit is contained in:
Sergio Gómez 2023-05-26 11:29:10 -05:00 committed by Marius Vlad
parent beece0215f
commit d53efc6cc3
2 changed files with 9 additions and 1 deletions

View File

@ -325,7 +325,7 @@ kiosk_shell_surface_set_parent(struct kiosk_shell_surface *shsurf,
if (shsurf->parent) {
shsurf->parent_destroy_listener.notify =
kiosk_shell_surface_notify_parent_destroy;
wl_signal_add(&shsurf->parent->destroy_signal,
wl_signal_add(&parent->parent_destroy_signal,
&shsurf->parent_destroy_listener);
if (!kiosk_shell_surface_is_surface_in_tree(shsurf, shroot)) {
@ -432,6 +432,7 @@ kiosk_shell_surface_create(struct kiosk_shell *shell,
weston_desktop_surface_set_user_data(desktop_surface, shsurf);
wl_signal_init(&shsurf->destroy_signal);
wl_signal_init(&shsurf->parent_destroy_signal);
/* start life inserting itself as root of its own surface tree list */
wl_list_init(&shsurf->surface_tree_list);
@ -810,6 +811,11 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
seat = get_kiosk_shell_first_seat(shell);
kiosk_seat = get_kiosk_shell_seat(seat);
/* Inform children about destruction of their parent, so that we can
* reparent them and potentially relink surface tree links before
* finding a focus successor and activating a new surface. */
wl_signal_emit(&shsurf->parent_destroy_signal, shsurf);
if (seat && kiosk_seat) {
focus_view = find_focus_successor(&shell->inactive_layer, shsurf,
kiosk_seat->focused_surface);

View File

@ -60,6 +60,8 @@ struct kiosk_shell_surface {
struct wl_listener output_destroy_listener;
struct wl_signal destroy_signal;
struct wl_signal parent_destroy_signal;
struct wl_listener parent_destroy_listener;
struct kiosk_shell_surface *parent;