From c7f6981d9cdbdb27c415071487ad7974e5b1a94a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 31 May 2017 16:17:04 -0400 Subject: Clean up outputs on exit --- example/main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'example') diff --git a/example/main.c b/example/main.c index 6fd7010c..33e77f5e 100644 --- a/example/main.c +++ b/example/main.c @@ -66,8 +66,21 @@ void output_add(struct wl_listener *listener, void *data) { void output_remove(struct wl_listener *listener, void *data) { struct wlr_output *output = data; - fprintf(stderr, "Output '%s' removed\n", output->name); - // TODO: remove signal from state->output_frame + struct output_state *ostate = NULL; + struct state *state = wl_container_of(listener, state, output_remove); + size_t i; + for (i = 0; i < state->outputs->length; ++i) { + struct output_state *_ostate = state->outputs->items[i]; + if (_ostate->output == output) { + ostate = _ostate; + break; + } + } + if (!ostate) { + return; // We are unfamiliar with this output + } + list_del(state->outputs, i); + wl_list_remove(&ostate->frame.link); } int timer_done(void *data) { -- cgit v1.2.3