From 28842f210dcf9ecbb3db497a7886029d6155f1b6 Mon Sep 17 00:00:00 2001 From: Emre Ucan Date: Wed, 6 Jun 2018 12:32:47 +0200 Subject: [PATCH] ivi-shell: listen output_destroyed_signal listen the signal and destroy the screen corresponding to the destroyed weston_output. clear also pending and order layer lists and unmap all active views on the screen. Signed-off-by: Emre Ucan The controller should decide what to do with the views. It can destroy the views or move the view to other screen. So, don't unmap the views on the destroy screen event in ivi-layout. Removing typecast Signed-off-by: Tran Ba Khang(MS/EMC31-XC) --- ivi-shell/ivi-layout-private.h | 1 + ivi-shell/ivi-layout.c | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h index 5c01f2453..7aef41587 100644 --- a/ivi-shell/ivi-layout-private.h +++ b/ivi-shell/ivi-layout-private.h @@ -117,6 +117,7 @@ struct ivi_layout { struct wl_list pending_transition_list; /* transition_node::link */ struct wl_listener output_created; + struct wl_listener output_destroyed; }; struct ivi_layout *get_instance(void); diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index 3b3549067..0364ac123 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -260,6 +260,44 @@ ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf) free(ivisurf); } +static void +destroy_screen(struct ivi_layout_screen *iviscrn) +{ + struct ivi_layout_layer *ivilayer, *layer_next; + + wl_list_for_each_safe(ivilayer, layer_next, + &iviscrn->pending.layer_list, pending.link) { + wl_list_remove(&ivilayer->pending.link); + wl_list_init(&ivilayer->pending.link); + } + + assert(wl_list_empty(&iviscrn->pending.layer_list)); + + wl_list_for_each_safe(ivilayer, layer_next, + &iviscrn->order.layer_list, order.link) { + wl_list_remove(&ivilayer->order.link); + wl_list_init(&ivilayer->order.link); + ivilayer->on_screen = NULL; + } + + assert(wl_list_empty(&iviscrn->order.layer_list)); + + wl_list_remove(&iviscrn->link); + free(iviscrn); +} + +static void +output_destroyed_event(struct wl_listener *listener, void *data) +{ + struct weston_output *destroyed_output = data; + struct ivi_layout_screen *iviscrn; + + iviscrn = get_screen_from_output(destroyed_output); + assert(iviscrn != NULL); + destroy_screen(iviscrn); + +} + static void add_screen(struct weston_output *output) { @@ -2058,6 +2096,9 @@ ivi_layout_init_with_compositor(struct weston_compositor *ec) layout->output_created.notify = output_created_event; wl_signal_add(&ec->output_created_signal, &layout->output_created); + layout->output_destroyed.notify = output_destroyed_event; + wl_signal_add(&ec->output_destroyed_signal, &layout->output_destroyed); + layout->transitions = ivi_layout_transition_set_create(ec); wl_list_init(&layout->pending_transition_list); @@ -2075,6 +2116,7 @@ ivi_layout_fini(void) /* XXX: tear down everything else */ wl_list_remove(&layout->output_created.link); + wl_list_remove(&layout->output_destroyed.link); } static struct ivi_layout_interface ivi_layout_interface = {