ivi-shell: clear seat focus if necessary when a surface is destroyed

Otherwise shseat->focused_ivisurf can point to deleted memory.
This does not happen with the hmi-controller because it explicitly assigns a new
focused surface. But the ivi-shell should not relay on the controller here.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Michael Olbrich 2023-12-13 09:58:28 +01:00 committed by Marius Vlad
parent dbd134ca5a
commit d6681cedee
1 changed files with 7 additions and 0 deletions

View File

@ -220,12 +220,19 @@ ivi_shell_surface_get_label(struct weston_surface *surface,
static void
layout_surface_cleanup(struct ivi_shell_surface *ivisurf)
{
struct weston_seat *seat;
assert(ivisurf->layout_surface != NULL);
/* destroy weston_surface destroy signal. */
if (!ivisurf->layout_surface->weston_desktop_surface)
wl_list_remove(&ivisurf->surface_destroy_listener.link);
wl_list_for_each(seat, &ivisurf->surface->compositor->seat_list, link) {
struct ivi_shell_seat *shseat = get_ivi_shell_seat(seat);
if (shseat->focused_ivisurf == ivisurf->layout_surface)
shseat->focused_ivisurf = NULL;
}
ivi_layout_surface_destroy(ivisurf->layout_surface);
ivisurf->layout_surface = NULL;