aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-05-31 16:17:04 -0400
committerDrew DeVault <sir@cmpwn.com>2017-05-31 16:17:04 -0400
commitc7f6981d9cdbdb27c415071487ad7974e5b1a94a (patch)
tree8ca48ad4fe61988a17f1f5dda31841b6be94dcb2 /example
parent579909a36857575ee23a39abc82d4e3b34096385 (diff)
Clean up outputs on exit
Diffstat (limited to 'example')
-rw-r--r--example/main.c17
1 files changed, 15 insertions, 2 deletions
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) {