Got to exit cleanly and to work with wlroots 0.18 again

This commit is contained in:
Keith Bowes 2025-02-18 23:31:59 -05:00
parent a6e9a04495
commit b2e686171f
6 changed files with 34 additions and 16 deletions

View file

@ -97,6 +97,7 @@ struct wb_server {
struct wl_listener new_input;
struct wl_listener new_output;
struct wl_listener output_configuration_applied;
struct wl_listener output_configuration_tested;
struct wl_list outputs; /* wb_output::link */
};

View file

@ -240,6 +240,14 @@ void wb_cursor_destroy(struct wb_cursor *cursor) {
return;
}
wl_list_remove(&cursor->request_cursor.link);
wl_list_remove(&cursor->cursor_motion.link);
wl_list_remove(&cursor->cursor_motion_absolute.link);
wl_list_remove(&cursor->cursor_button.link);
wl_list_remove(&cursor->cursor_axis.link);
wl_list_remove(&cursor->cursor_frame.link);
wlr_xcursor_manager_destroy(cursor->xcursor_manager);
wlr_cursor_destroy(cursor->cursor);
free(cursor);

View file

@ -4,6 +4,7 @@
static void idle_inhibit_manager_destroy(struct wl_listener *listener, void *data) {
struct wb_server *server = wl_container_of(listener, server, destroy_inhibit_manager);
wl_list_remove(&server->new_inhibitor.link);
wl_list_remove(&server->inhibitors);
}
@ -11,6 +12,7 @@ static void idle_inhibitor_destroy(struct wl_listener *listener, void *data) {
struct wb_server *server = wl_container_of(listener, server, destroy_inhibitor);
/* wlroots will destroy the inhibitor after this callback, so this number will be 1 if the
* last inhibitor is being destroyed. */
wl_list_remove(&server->destroy_inhibitor.link);
wlr_idle_notifier_v1_set_inhibited(server->idle_notifier,
wl_list_length(&server->inhibitors) > 1);
}

View file

@ -204,6 +204,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
arrange_layers(surface->output);
}
wl_list_remove(&surface->new_popup.link);
wb_layer_surface_destroy(surface);
}

View file

@ -55,6 +55,10 @@ void output_configuration_applied(struct wl_listener *listener, void *data) {
wlr_output_configuration_v1_send_succeeded(configuration);
}
void output_configuration_tested(struct wl_listener *listener, void *data) {
output_configuration_applied(listener, data);
}
void output_request_state_notify(struct wl_listener *listener, void *data) {
struct wb_output *output = wl_container_of(listener, output, request_state);
const struct wlr_output_event_request_state *event = data;
@ -175,5 +179,5 @@ void init_output(struct wb_server *server) {
server->wlr_output_manager = wlr_output_manager_v1_create(server->wl_display);
server->output_configuration_applied.notify = output_configuration_applied;
wl_signal_add(&server->wlr_output_manager->events.apply, &server->output_configuration_applied);
wl_signal_add(&server->wlr_output_manager->events.test, &server->output_configuration_applied);
wl_signal_add(&server->wlr_output_manager->events.test, &server->output_configuration_tested);
}

View file

@ -142,25 +142,27 @@ bool wb_terminate(struct wb_server* server) {
wlr_output_layout_destroy(server->output_layout);
wlr_allocator_destroy(server->allocator);
wlr_renderer_destroy(server->renderer);
wlr_backend_destroy(server->backend);
wl_display_destroy(server->wl_display);
wb_seat_destroy(server->seat);
wl_list_remove(&server->gamma_control_set_gamma.link);
wl_list_remove(&server->new_layer_surface.link);
wl_list_remove(&server->new_xdg_decoration.link);
wl_list_remove(&server->destroy_inhibit_manager.link);
wl_list_remove(&server->destroy_inhibitor.link);
wl_list_remove(&server->new_inhibitor.link);
wl_list_remove(&server->inhibitors);
wl_list_remove(&server->new_xdg_toplevel.link);
wl_list_remove(&server->new_xdg_popup.link);
wl_list_remove(&server->new_input.link);
wl_list_remove(&server->new_output.link);
wl_list_remove(&server->output_configuration_applied.link);
wl_list_remove(&server->output_configuration_tested.link);
wl_list_remove(&server->new_inhibitor.link);
wl_list_remove(&server->inhibitors);
wl_list_remove(&server->destroy_inhibit_manager.link);
wl_list_remove(&server->gamma_control_set_gamma.link);
wl_list_remove(&server->new_layer_surface.link);
#if WLR_CHECK_VERSION(0, 18, 0)
wl_list_remove(&server->new_xdg_toplevel.link);
wl_list_remove(&server->new_xdg_popup.link);
#else
wl_list_remove(&server->new_xdg_surface.link);
#endif
wlr_backend_destroy(server->backend);
wb_seat_destroy(server->seat);
wl_display_destroy(server->wl_display);
wlr_scene_node_destroy(&server->scene->tree.node);
wlr_log(WLR_INFO, "%s", _("Display destroyed"));