diff --git a/include/decorations.h b/include/decorations.h index a77a7c58..4d23c14f 100644 --- a/include/decorations.h +++ b/include/decorations.h @@ -12,4 +12,7 @@ void xdg_server_decoration_init(struct server *server); void kde_server_decoration_update_default(void); void kde_server_decoration_set_view(struct view *view, struct wlr_surface *surface); +void kde_server_decoration_finish(struct server *server); +void xdg_server_decoration_finish(struct server *server); + #endif /* LABWC_DECORATIONS_H */ diff --git a/include/labwc.h b/include/labwc.h index d7f43217..8d9fe8cc 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -435,6 +435,7 @@ struct constraint { void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup); void xdg_shell_init(struct server *server); +void xdg_shell_finish(struct server *server); /* * desktop.c routines deal with a collection of views @@ -539,6 +540,7 @@ void interactive_cancel(struct view *view); enum view_edge edge_from_cursor(struct seat *seat, struct output **dest_output); void output_init(struct server *server); +void output_finish(struct server *server); void output_manager_init(struct server *server); struct output *output_from_wlr_output(struct server *server, struct wlr_output *wlr_output); diff --git a/include/layers.h b/include/layers.h index 2b816a19..489bf9e2 100644 --- a/include/layers.h +++ b/include/layers.h @@ -37,6 +37,7 @@ struct lab_layer_popup { }; void layers_init(struct server *server); +void layers_finish(struct server *server); void layers_arrange(struct output *output); void layer_try_set_focus(struct seat *seat, diff --git a/src/decorations/kde-deco.c b/src/decorations/kde-deco.c index 065f89fd..a615811b 100644 --- a/src/decorations/kde-deco.c +++ b/src/decorations/kde-deco.c @@ -133,3 +133,8 @@ kde_server_decoration_init(struct server *server) server->kde_server_decoration.notify = handle_new_server_decoration; } +void +kde_server_decoration_finish(struct server *server) +{ + wl_list_remove(&server->kde_server_decoration.link); +} diff --git a/src/decorations/xdg-deco.c b/src/decorations/xdg-deco.c index 219c33ac..d69808e6 100644 --- a/src/decorations/xdg-deco.c +++ b/src/decorations/xdg-deco.c @@ -127,3 +127,9 @@ xdg_server_decoration_init(struct server *server) &server->xdg_toplevel_decoration); server->xdg_toplevel_decoration.notify = xdg_toplevel_decoration; } + +void +xdg_server_decoration_finish(struct server *server) +{ + wl_list_remove(&server->xdg_toplevel_decoration.link); +} diff --git a/src/idle.c b/src/idle.c index 844b17bb..568b680f 100644 --- a/src/idle.c +++ b/src/idle.c @@ -17,9 +17,9 @@ struct lab_idle_manager { struct { struct wlr_idle_inhibit_manager_v1 *manager; struct wl_listener on_new_inhibitor; + struct wl_listener on_destroy; } inhibitor; struct wlr_seat *wlr_seat; - struct wl_listener on_display_destroy; }; static struct lab_idle_manager *manager; @@ -59,13 +59,10 @@ handle_idle_inhibitor_new(struct wl_listener *listener, void *data) } static void -handle_display_destroy(struct wl_listener *listener, void *data) +handle_inhibitor_manager_destroy(struct wl_listener *listener, void *data) { - /* - * All the managers will react to the display - * destroy signal as well and thus clean up. - */ - wl_list_remove(&manager->on_display_destroy.link); + wl_list_remove(&manager->inhibitor.on_new_inhibitor.link); + wl_list_remove(&manager->inhibitor.on_destroy.link); zfree(manager); } @@ -83,8 +80,9 @@ idle_manager_create(struct wl_display *display, struct wlr_seat *wlr_seat) wl_signal_add(&manager->inhibitor.manager->events.new_inhibitor, &manager->inhibitor.on_new_inhibitor); - manager->on_display_destroy.notify = handle_display_destroy; - wl_display_add_destroy_listener(display, &manager->on_display_destroy); + manager->inhibitor.on_destroy.notify = handle_inhibitor_manager_destroy; + wl_signal_add(&manager->inhibitor.manager->events.destroy, + &manager->inhibitor.on_destroy); } void diff --git a/src/input/cursor.c b/src/input/cursor.c index e9ae9ad0..4c6c3e00 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -1527,6 +1527,7 @@ void cursor_finish(struct seat *seat) wl_list_remove(&seat->request_cursor.link); wl_list_remove(&seat->request_set_shape.link); wl_list_remove(&seat->request_set_selection.link); + wl_list_remove(&seat->request_set_primary_selection.link); wlr_xcursor_manager_destroy(seat->xcursor_manager); wlr_cursor_destroy(seat->cursor); diff --git a/src/layers.c b/src/layers.c index 6ce9527d..9b4dcdc8 100644 --- a/src/layers.c +++ b/src/layers.c @@ -600,3 +600,9 @@ layers_init(struct server *server) wl_signal_add(&server->layer_shell->events.new_surface, &server->new_layer_surface); } + +void +layers_finish(struct server *server) +{ + wl_list_remove(&server->new_layer_surface.link); +} diff --git a/src/output.c b/src/output.c index 2d0368a8..1221376c 100644 --- a/src/output.c +++ b/src/output.c @@ -572,6 +572,15 @@ output_init(struct server *server) output_manager_init(server); } +static void output_manager_finish(struct server *server); + +void +output_finish(struct server *server) +{ + wl_list_remove(&server->new_output.link); + output_manager_finish(server); +} + static void output_update_for_layout_change(struct server *server) { @@ -890,6 +899,15 @@ output_manager_init(struct server *server) &server->gamma_control_set_gamma); } +static void +output_manager_finish(struct server *server) +{ + wl_list_remove(&server->output_layout_change.link); + wl_list_remove(&server->output_manager_apply.link); + wl_list_remove(&server->output_manager_test.link); + wl_list_remove(&server->gamma_control_set_gamma.link); +} + struct output * output_from_wlr_output(struct server *server, struct wlr_output *wlr_output) { diff --git a/src/seat.c b/src/seat.c index c72cb186..09729f38 100644 --- a/src/seat.c +++ b/src/seat.c @@ -588,6 +588,8 @@ seat_finish(struct server *server) struct seat *seat = &server->seat; wl_list_remove(&seat->new_input.link); wl_list_remove(&seat->focus_change.link); + wl_list_remove(&seat->virtual_pointer_new.link); + wl_list_remove(&seat->virtual_keyboard_new.link); struct input *input, *next; wl_list_for_each_safe(input, next, &seat->inputs, link) { diff --git a/src/server.c b/src/server.c index 03fd5cd0..ede643be 100644 --- a/src/server.c +++ b/src/server.c @@ -752,12 +752,26 @@ server_finish(struct server *server) wl_event_source_remove(sighup_source); } wl_display_destroy_clients(server->wl_display); + + seat_finish(server); + output_finish(server); + xdg_shell_finish(server); + layers_finish(server); + kde_server_decoration_finish(server); + xdg_server_decoration_finish(server); + wl_list_remove(&server->new_constraint.link); + wl_list_remove(&server->output_power_manager_set_mode.link); + wl_list_remove(&server->tearing_new_object.link); + wlr_backend_destroy(server->backend); wlr_allocator_destroy(server->allocator); + + wl_list_remove(&server->renderer_lost.link); wlr_renderer_destroy(server->renderer); - seat_finish(server); + workspaces_destroy(server); wlr_scene_node_destroy(&server->scene->tree.node); + wl_display_destroy(server->wl_display); free(server->ssd_hover_state); } diff --git a/src/xdg.c b/src/xdg.c index cd2200f2..b2fc4601 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -1017,3 +1017,10 @@ xdg_shell_init(struct server *server) &server->xdg_activation_new_token); } +void +xdg_shell_finish(struct server *server) +{ + wl_list_remove(&server->new_xdg_toplevel.link); + wl_list_remove(&server->xdg_activation_request.link); + wl_list_remove(&server->xdg_activation_new_token.link); +} diff --git a/src/xwayland.c b/src/xwayland.c index 1eb9c1a3..f0cfc5ae 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -1242,6 +1242,10 @@ void xwayland_server_finish(struct server *server) { struct wlr_xwayland *xwayland = server->xwayland; + wl_list_remove(&server->xwayland_new_surface.link); + wl_list_remove(&server->xwayland_server_ready.link); + wl_list_remove(&server->xwayland_xwm_ready.link); + /* * Reset server->xwayland to NULL first to prevent callbacks (like * server_global_filter) from accessing it as it is destroyed