diff --git a/kiwmi/desktop/layer_shell.c b/kiwmi/desktop/layer_shell.c index 78e4a34..3acb3b7 100644 --- a/kiwmi/desktop/layer_shell.c +++ b/kiwmi/desktop/layer_shell.c @@ -24,12 +24,14 @@ kiwmi_layer_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) { struct kiwmi_layer *layer = wl_container_of(listener, layer, destroy); - wl_list_remove(&layer->link); wl_list_remove(&layer->destroy.link); wl_list_remove(&layer->map.link); wl_list_remove(&layer->unmap.link); - arrange_layers(layer->output); + if (layer->output != NULL) { + wl_list_remove(&layer->link); + arrange_layers(layer->output); + } free(layer); } diff --git a/kiwmi/desktop/output.c b/kiwmi/desktop/output.c index eeb62f3..dda2a49 100644 --- a/kiwmi/desktop/output.c +++ b/kiwmi/desktop/output.c @@ -276,6 +276,17 @@ output_destroy_notify(struct wl_listener *listener, void *UNUSED(data)) wl_list_remove(&output->events.destroy.listener_list); + int n_layers = sizeof(output->layers) / sizeof(output->layers[0]); + for (int i = 0; i < n_layers; i++) { + struct kiwmi_layer *layer; + struct kiwmi_layer *tmp; + wl_list_for_each_safe (layer, tmp, &output->layers[i], link) { + wl_list_remove(&layer->link); + layer->output = NULL; + wlr_layer_surface_v1_destroy(layer->layer_surface); + } + } + free(output); } @@ -384,5 +395,7 @@ new_output_notify(struct wl_listener *listener, void *data) void output_damage(struct kiwmi_output *output) { - output->damaged = 2; + if (output != NULL) { + output->damaged = 2; + } }