From 2c1426a72f33a2c1949e26efbd137c3e1b888762 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 16 Dec 2011 11:35:34 +0200 Subject: [PATCH] window: destroy outputs on display_destroy() This will also start calling the output destroy handlers, if an application has set any. Signed-off-by: Pekka Paalanen --- clients/window.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clients/window.c b/clients/window.c index 3f6dafcd..c1aee89e 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2232,6 +2232,17 @@ display_add_output(struct display *d, uint32_t id) wl_output_add_listener(output->output, &output_listener, output); } +static void +output_destroy(struct output *output) +{ + if (output->destroy_handler) + (*output->destroy_handler)(output, output->user_data); + + wl_output_destroy(output->output); + wl_list_remove(&output->link); + free(output); +} + void display_set_output_configure_handler(struct display *display, display_output_handler_t handler) @@ -2583,9 +2594,21 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries) return d; } +static void +display_destroy_outputs(struct display *display) +{ + struct output *tmp; + struct output *output; + + wl_list_for_each_safe(output, tmp, &display->output_list, link) + output_destroy(output); +} + void display_destroy(struct display *display) { + display_destroy_outputs(display); + fini_xkb(display); fini_egl(display);