diff --git a/backend/backend.c b/backend/backend.c index fdba79c55..b8a9d71cc 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -48,6 +48,10 @@ void wlr_backend_init(struct wlr_backend *backend, void wlr_backend_finish(struct wlr_backend *backend) { wl_signal_emit_mutable(&backend->events.destroy, backend); + + assert(wl_list_empty(&backend->events.destroy.listener_list)); + assert(wl_list_empty(&backend->events.new_input.listener_list)); + assert(wl_list_empty(&backend->events.new_output.listener_list)); } bool wlr_backend_start(struct wlr_backend *backend) { diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 237a0efe9..6ae9dcbf3 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -2177,6 +2177,8 @@ void drm_lease_destroy(struct wlr_drm_lease *lease) { wl_signal_emit_mutable(&lease->events.destroy, NULL); + assert(wl_list_empty(&lease->events.destroy.listener_list)); + struct wlr_drm_connector *conn; wl_list_for_each(conn, &drm->connectors, link) { if (conn->lease == lease) { diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 41ef31ccb..3d8fb96f5 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -51,6 +51,9 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) { wlr_backend_finish(wlr_backend); + assert(wl_list_empty(&backend->events.backend_add.listener_list)); + assert(wl_list_empty(&backend->events.backend_remove.listener_list)); + // Some backends may depend on other backends, ie. destroying a backend may // also destroy other backends while (!wl_list_empty(&backend->backends)) { diff --git a/backend/session/session.c b/backend/session/session.c index b0b2894b4..dcf07c708 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -303,6 +303,11 @@ void wlr_session_destroy(struct wlr_session *session) { } wl_signal_emit_mutable(&session->events.destroy, session); + + assert(wl_list_empty(&session->events.active.listener_list)); + assert(wl_list_empty(&session->events.add_drm_card.listener_list)); + assert(wl_list_empty(&session->events.destroy.listener_list)); + wl_list_remove(&session->event_loop_destroy.link); wl_event_source_remove(session->udev_event); @@ -360,6 +365,10 @@ void wlr_session_close_file(struct wlr_session *session, if (libseat_close_device(session->seat_handle, dev->device_id) == -1) { wlr_log_errno(WLR_ERROR, "Failed to close device %d", dev->device_id); } + + assert(wl_list_empty(&dev->events.change.listener_list)); + assert(wl_list_empty(&dev->events.remove.listener_list)); + close(dev->fd); wl_list_remove(&dev->link); free(dev); diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index 4fd5211a8..b7dbf3d65 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -28,6 +28,7 @@ void wlr_allocator_init(struct wlr_allocator *alloc, .impl = impl, .buffer_caps = buffer_caps, }; + wl_signal_init(&alloc->events.destroy); } @@ -173,6 +174,9 @@ void wlr_allocator_destroy(struct wlr_allocator *alloc) { return; } wl_signal_emit_mutable(&alloc->events.destroy, NULL); + + assert(wl_list_empty(&alloc->events.destroy.listener_list)); + alloc->impl->destroy(alloc); } diff --git a/render/drm_syncobj.c b/render/drm_syncobj.c index 9e5569fb4..7d52f4118 100644 --- a/render/drm_syncobj.c +++ b/render/drm_syncobj.c @@ -241,7 +241,8 @@ bool wlr_drm_syncobj_timeline_waiter_init(struct wlr_drm_syncobj_timeline_waiter } void wlr_drm_syncobj_timeline_waiter_finish(struct wlr_drm_syncobj_timeline_waiter *waiter) { - wl_list_remove(&waiter->events.ready.listener_list); + assert(wl_list_empty(&waiter->events.ready.listener_list)); + wl_event_source_remove(waiter->event_source); close(waiter->ev_fd); } diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index ae324afb9..eb6b9e97f 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -51,6 +51,9 @@ void wlr_renderer_destroy(struct wlr_renderer *r) { wl_signal_emit_mutable(&r->events.destroy, r); + assert(wl_list_empty(&r->events.destroy.listener_list)); + assert(wl_list_empty(&r->events.lost.listener_list)); + if (r->impl && r->impl->destroy) { r->impl->destroy(r); } else { diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 915938485..89837b4fb 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -1053,9 +1053,26 @@ int main(int argc, char *argv[]) { socket); wl_display_run(server.wl_display); + /* Once wl_display_run returns, we destroy all clients then shut down the * server. */ wl_display_destroy_clients(server.wl_display); + + wl_list_remove(&server.new_xdg_toplevel.link); + wl_list_remove(&server.new_xdg_popup.link); + + wl_list_remove(&server.cursor_motion.link); + wl_list_remove(&server.cursor_motion_absolute.link); + wl_list_remove(&server.cursor_button.link); + wl_list_remove(&server.cursor_axis.link); + wl_list_remove(&server.cursor_frame.link); + + wl_list_remove(&server.new_input.link); + wl_list_remove(&server.request_cursor.link); + wl_list_remove(&server.request_set_selection.link); + + wl_list_remove(&server.new_output.link); + wlr_scene_node_destroy(&server.scene->tree.node); wlr_xcursor_manager_destroy(server.cursor_mgr); wlr_cursor_destroy(server.cursor); diff --git a/types/buffer/buffer.c b/types/buffer/buffer.c index 1438b27b2..2a7576c7e 100644 --- a/types/buffer/buffer.c +++ b/types/buffer/buffer.c @@ -17,14 +17,19 @@ void wlr_buffer_init(struct wlr_buffer *buffer, .width = width, .height = height, }; + wl_signal_init(&buffer->events.destroy); wl_signal_init(&buffer->events.release); + wlr_addon_set_init(&buffer->addons); } void wlr_buffer_finish(struct wlr_buffer *buffer) { wl_signal_emit_mutable(&buffer->events.destroy, NULL); wlr_addon_set_finish(&buffer->addons); + + assert(wl_list_empty(&buffer->events.destroy.listener_list)); + assert(wl_list_empty(&buffer->events.release.listener_list)); } static void buffer_consider_destroy(struct wlr_buffer *buffer) { diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c index 3b5b8a668..ad7966d36 100644 --- a/types/data_device/wlr_data_device.c +++ b/types/data_device/wlr_data_device.c @@ -284,6 +284,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_data_device_manager *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c index 15fb9929e..64b73c56e 100644 --- a/types/data_device/wlr_data_source.c +++ b/types/data_device/wlr_data_source.c @@ -41,6 +41,8 @@ void wlr_data_source_destroy(struct wlr_data_source *source) { wl_signal_emit_mutable(&source->events.destroy, source); + assert(wl_list_empty(&source->events.destroy.listener_list)); + char **p; wl_array_for_each(p, &source->mime_types) { free(*p); diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index b1d348949..b780eedac 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -123,6 +123,9 @@ static void drag_icon_destroy(struct wlr_drag_icon *icon) { icon->drag->icon = NULL; wl_list_remove(&icon->surface_destroy.link); wl_signal_emit_mutable(&icon->events.destroy, icon); + + assert(wl_list_empty(&icon->events.destroy.listener_list)); + free(icon); } @@ -160,6 +163,11 @@ static void drag_destroy(struct wlr_drag *drag) { // signal handler. wl_signal_emit_mutable(&drag->events.destroy, drag); + assert(wl_list_empty(&drag->events.focus.listener_list)); + assert(wl_list_empty(&drag->events.motion.listener_list)); + assert(wl_list_empty(&drag->events.drop.listener_list)); + assert(wl_list_empty(&drag->events.destroy.listener_list)); + if (drag->source) { wl_list_remove(&drag->source_destroy.link); } diff --git a/types/ext_image_capture_source_v1/base.c b/types/ext_image_capture_source_v1/base.c index 0fc910864..7b34030c8 100644 --- a/types/ext_image_capture_source_v1/base.c +++ b/types/ext_image_capture_source_v1/base.c @@ -149,4 +149,5 @@ void wlr_ext_image_capture_source_v1_cursor_init(struct wlr_ext_image_capture_so void wlr_ext_image_capture_source_v1_cursor_finish(struct wlr_ext_image_capture_source_v1_cursor *source_cursor) { wlr_ext_image_capture_source_v1_finish(&source_cursor->base); + assert(wl_list_empty(&source_cursor->events.update.listener_list)); } diff --git a/types/output/output.c b/types/output/output.c index 7bfdf9c77..a352a5e59 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -349,6 +349,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, wl_list_init(&output->cursors); wl_list_init(&output->layers); wl_list_init(&output->resources); + wl_signal_init(&output->events.frame); wl_signal_init(&output->events.damage); wl_signal_init(&output->events.needs_frame); @@ -377,13 +378,23 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, void wlr_output_finish(struct wlr_output *output) { wl_signal_emit_mutable(&output->events.destroy, output); + wlr_addon_set_finish(&output->addons); + + assert(wl_list_empty(&output->events.frame.listener_list)); + assert(wl_list_empty(&output->events.damage.listener_list)); + assert(wl_list_empty(&output->events.needs_frame.listener_list)); + assert(wl_list_empty(&output->events.precommit.listener_list)); + assert(wl_list_empty(&output->events.commit.listener_list)); + assert(wl_list_empty(&output->events.present.listener_list)); + assert(wl_list_empty(&output->events.bind.listener_list)); + assert(wl_list_empty(&output->events.description.listener_list)); + assert(wl_list_empty(&output->events.request_state.listener_list)); + assert(wl_list_empty(&output->events.destroy.listener_list)); wlr_output_destroy_global(output); wl_list_remove(&output->display_destroy.link); - wlr_addon_set_finish(&output->addons); - // The backend is responsible for free-ing the list of modes struct wlr_output_cursor *cursor, *tmp_cursor; diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 58d1cc3f0..9a6266381 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -833,6 +833,7 @@ struct wlr_scene_buffer *wlr_scene_buffer_create(struct wlr_scene_tree *parent, wl_signal_init(&scene_buffer->events.output_leave); wl_signal_init(&scene_buffer->events.output_sample); wl_signal_init(&scene_buffer->events.frame_done); + pixman_region32_init(&scene_buffer->opaque_region); wl_list_init(&scene_buffer->buffer_release.link); wl_list_init(&scene_buffer->renderer_destroy.link); diff --git a/types/seat/wlr_seat.c b/types/seat/wlr_seat.c index 5ca69aac8..015a57b52 100644 --- a/types/seat/wlr_seat.c +++ b/types/seat/wlr_seat.c @@ -71,6 +71,8 @@ static void seat_handle_get_touch(struct wl_client *client, static void seat_client_destroy(struct wlr_seat_client *client) { wl_signal_emit_mutable(&client->events.destroy, client); + assert(wl_list_empty(&client->events.destroy.listener_list)); + if (client == client->seat->pointer_state.focused_client) { client->seat->pointer_state.focused_client = NULL; } @@ -151,6 +153,7 @@ static struct wlr_seat_client *seat_client_create(struct wlr_seat *wlr_seat, wl_list_init(&seat_client->keyboards); wl_list_init(&seat_client->touches); wl_list_init(&seat_client->data_devices); + wl_signal_init(&seat_client->events.destroy); wl_list_insert(&wlr_seat->clients, &seat_client->link); @@ -227,6 +230,31 @@ void wlr_seat_destroy(struct wlr_seat *seat) { wl_signal_emit_mutable(&seat->events.destroy, seat); + assert(wl_list_empty(&seat->pointer_state.events.focus_change.listener_list)); + + assert(wl_list_empty(&seat->keyboard_state.events.focus_change.listener_list)); + + assert(wl_list_empty(&seat->events.request_start_drag.listener_list)); + assert(wl_list_empty(&seat->events.start_drag.listener_list)); + + assert(wl_list_empty(&seat->events.request_set_cursor.listener_list)); + + assert(wl_list_empty(&seat->events.request_set_selection.listener_list)); + assert(wl_list_empty(&seat->events.set_selection.listener_list)); + assert(wl_list_empty(&seat->events.request_set_primary_selection.listener_list)); + assert(wl_list_empty(&seat->events.set_primary_selection.listener_list)); + + assert(wl_list_empty(&seat->events.pointer_grab_begin.listener_list)); + assert(wl_list_empty(&seat->events.pointer_grab_end.listener_list)); + + assert(wl_list_empty(&seat->events.keyboard_grab_begin.listener_list)); + assert(wl_list_empty(&seat->events.keyboard_grab_end.listener_list)); + + assert(wl_list_empty(&seat->events.touch_grab_begin.listener_list)); + assert(wl_list_empty(&seat->events.touch_grab_end.listener_list)); + + assert(wl_list_empty(&seat->events.destroy.listener_list)); + wl_list_remove(&seat->display_destroy.link); wlr_data_source_destroy(seat->selection_source); diff --git a/types/seat/wlr_seat_touch.c b/types/seat/wlr_seat_touch.c index 6aac48841..03b72f698 100644 --- a/types/seat/wlr_seat_touch.c +++ b/types/seat/wlr_seat_touch.c @@ -107,6 +107,8 @@ static void touch_point_clear_focus(struct wlr_touch_point *point) { static void touch_point_destroy(struct wlr_touch_point *point) { wl_signal_emit_mutable(&point->events.destroy, point); + assert(wl_list_empty(&point->events.destroy.listener_list)); + touch_point_clear_focus(point); wl_list_remove(&point->surface_destroy.link); wl_list_remove(&point->client_destroy.link); diff --git a/types/tablet_v2/wlr_tablet_v2.c b/types/tablet_v2/wlr_tablet_v2.c index 28671c9b0..a0cf2fa67 100644 --- a/types/tablet_v2/wlr_tablet_v2.c +++ b/types/tablet_v2/wlr_tablet_v2.c @@ -270,6 +270,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_tablet_manager_v2 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); struct wlr_tablet_seat_v2 *seat, *tmp; @@ -296,6 +299,7 @@ struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display) { } wl_signal_init(&tablet->events.destroy); + wl_list_init(&tablet->clients); wl_list_init(&tablet->seats); diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index 081af3539..afa35ec99 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -727,8 +727,15 @@ static void surface_handle_resource_destroy(struct wl_resource *resource) { surface_destroy_role_object(surface); wl_signal_emit_mutable(&surface->events.destroy, surface); - wlr_addon_set_finish(&surface->addons); + + assert(wl_list_empty(&surface->events.client_commit.listener_list)); + assert(wl_list_empty(&surface->events.commit.listener_list)); + assert(wl_list_empty(&surface->events.map.listener_list)); + assert(wl_list_empty(&surface->events.unmap.listener_list)); + assert(wl_list_empty(&surface->events.destroy.listener_list)); + assert(wl_list_empty(&surface->events.new_subsurface.listener_list)); + assert(wl_list_empty(&surface->synced)); struct wlr_surface_state *cached, *cached_tmp; @@ -782,6 +789,7 @@ static struct wlr_surface *surface_create(struct wl_client *client, wl_signal_init(&surface->events.unmap); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.new_subsurface); + wl_list_init(&surface->current_outputs); wl_list_init(&surface->cached); pixman_region32_init(&surface->buffer_damage); @@ -1337,6 +1345,10 @@ static void compositor_handle_display_destroy( struct wlr_compositor *compositor = wl_container_of(listener, compositor, display_destroy); wl_signal_emit_mutable(&compositor->events.destroy, NULL); + + assert(wl_list_empty(&compositor->events.new_surface.listener_list)); + assert(wl_list_empty(&compositor->events.destroy.listener_list)); + wl_list_remove(&compositor->display_destroy.link); wl_list_remove(&compositor->renderer_destroy.link); wl_global_destroy(compositor->global); @@ -1368,6 +1380,7 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display, wl_signal_init(&compositor->events.new_surface); wl_signal_init(&compositor->events.destroy); + wl_list_init(&compositor->renderer_destroy.link); compositor->display_destroy.notify = compositor_handle_display_destroy; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 7c2f56ace..44b74e926 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -247,6 +247,34 @@ static void cursor_reset_image(struct wlr_cursor *cur) { } void wlr_cursor_destroy(struct wlr_cursor *cur) { + // pointer signals + assert(wl_list_empty(&cur->events.motion.listener_list)); + assert(wl_list_empty(&cur->events.motion_absolute.listener_list)); + assert(wl_list_empty(&cur->events.button.listener_list)); + assert(wl_list_empty(&cur->events.axis.listener_list)); + assert(wl_list_empty(&cur->events.frame.listener_list)); + assert(wl_list_empty(&cur->events.swipe_begin.listener_list)); + assert(wl_list_empty(&cur->events.swipe_update.listener_list)); + assert(wl_list_empty(&cur->events.swipe_end.listener_list)); + assert(wl_list_empty(&cur->events.pinch_begin.listener_list)); + assert(wl_list_empty(&cur->events.pinch_update.listener_list)); + assert(wl_list_empty(&cur->events.pinch_end.listener_list)); + assert(wl_list_empty(&cur->events.hold_begin.listener_list)); + assert(wl_list_empty(&cur->events.hold_end.listener_list)); + + // touch signals + assert(wl_list_empty(&cur->events.touch_up.listener_list)); + assert(wl_list_empty(&cur->events.touch_down.listener_list)); + assert(wl_list_empty(&cur->events.touch_motion.listener_list)); + assert(wl_list_empty(&cur->events.touch_cancel.listener_list)); + assert(wl_list_empty(&cur->events.touch_frame.listener_list)); + + // tablet tool signals + assert(wl_list_empty(&cur->events.tablet_tool_tip.listener_list)); + assert(wl_list_empty(&cur->events.tablet_tool_axis.listener_list)); + assert(wl_list_empty(&cur->events.tablet_tool_button.listener_list)); + assert(wl_list_empty(&cur->events.tablet_tool_proximity.listener_list)); + cursor_reset_image(cur); cursor_detach_output_layout(cur); diff --git a/types/wlr_cursor_shape_v1.c b/types/wlr_cursor_shape_v1.c index 1bd1126bd..3e657fb6d 100644 --- a/types/wlr_cursor_shape_v1.c +++ b/types/wlr_cursor_shape_v1.c @@ -187,6 +187,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, NULL); + + assert(wl_list_empty(&manager->events.request_set_shape.listener_list)); assert(wl_list_empty(&manager->events.destroy.listener_list)); wl_global_destroy(manager->global); diff --git a/types/wlr_data_control_v1.c b/types/wlr_data_control_v1.c index 88f23ae46..2e26d703d 100644 --- a/types/wlr_data_control_v1.c +++ b/types/wlr_data_control_v1.c @@ -666,6 +666,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_data_control_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.new_device.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -678,6 +682,7 @@ struct wlr_data_control_manager_v1 *wlr_data_control_manager_v1_create( return NULL; } wl_list_init(&manager->devices); + wl_signal_init(&manager->events.destroy); wl_signal_init(&manager->events.new_device); diff --git a/types/wlr_drm.c b/types/wlr_drm.c index e7e57c3c6..f8db8291b 100644 --- a/types/wlr_drm.c +++ b/types/wlr_drm.c @@ -189,6 +189,8 @@ static const struct wlr_buffer_resource_interface buffer_resource_interface = { static void drm_destroy(struct wlr_drm *drm) { wl_signal_emit_mutable(&drm->events.destroy, NULL); + assert(wl_list_empty(&drm->events.destroy.listener_list)); + wl_list_remove(&drm->display_destroy.link); wlr_drm_format_set_finish(&drm->formats); diff --git a/types/wlr_drm_lease_v1.c b/types/wlr_drm_lease_v1.c index 52010ea0d..50097ae75 100644 --- a/types/wlr_drm_lease_v1.c +++ b/types/wlr_drm_lease_v1.c @@ -684,6 +684,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { wl_signal_emit_mutable(&manager->events.destroy, NULL); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.request.listener_list)); + struct wlr_drm_lease_device_v1 *device, *tmp; wl_list_for_each_safe(device, tmp, &manager->devices, link) { drm_lease_device_v1_destroy(device); diff --git a/types/wlr_export_dmabuf_v1.c b/types/wlr_export_dmabuf_v1.c index 69245e373..ea4a53880 100644 --- a/types/wlr_export_dmabuf_v1.c +++ b/types/wlr_export_dmabuf_v1.c @@ -192,6 +192,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_export_dmabuf_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -204,6 +207,7 @@ struct wlr_export_dmabuf_manager_v1 *wlr_export_dmabuf_manager_v1_create( return NULL; } wl_list_init(&manager->frames); + wl_signal_init(&manager->events.destroy); manager->global = wl_global_create(display, diff --git a/types/wlr_ext_foreign_toplevel_list_v1.c b/types/wlr_ext_foreign_toplevel_list_v1.c index a773ee8a2..432b27fc2 100644 --- a/types/wlr_ext_foreign_toplevel_list_v1.c +++ b/types/wlr_ext_foreign_toplevel_list_v1.c @@ -91,6 +91,8 @@ void wlr_ext_foreign_toplevel_handle_v1_destroy( wl_signal_emit_mutable(&toplevel->events.destroy, NULL); + assert(wl_list_empty(&toplevel->events.destroy.listener_list)); + struct wl_resource *resource, *tmp; wl_resource_for_each_safe(resource, tmp, &toplevel->resources) { ext_foreign_toplevel_handle_v1_send_closed(resource); @@ -253,6 +255,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_ext_foreign_toplevel_list_v1 *list = wl_container_of(listener, list, display_destroy); wl_signal_emit_mutable(&list->events.destroy, NULL); + + assert(wl_list_empty(&list->events.destroy.listener_list)); + wl_list_remove(&list->display_destroy.link); wl_global_destroy(list->global); free(list); @@ -277,6 +282,7 @@ struct wlr_ext_foreign_toplevel_list_v1 *wlr_ext_foreign_toplevel_list_v1_create } wl_signal_init(&list->events.destroy); + wl_list_init(&list->resources); wl_list_init(&list->toplevels); diff --git a/types/wlr_foreign_toplevel_management_v1.c b/types/wlr_foreign_toplevel_management_v1.c index db7e526fd..f06fdb7b7 100644 --- a/types/wlr_foreign_toplevel_management_v1.c +++ b/types/wlr_foreign_toplevel_management_v1.c @@ -452,6 +452,14 @@ void wlr_foreign_toplevel_handle_v1_destroy( wl_signal_emit_mutable(&toplevel->events.destroy, toplevel); + assert(wl_list_empty(&toplevel->events.request_maximize.listener_list)); + assert(wl_list_empty(&toplevel->events.request_minimize.listener_list)); + assert(wl_list_empty(&toplevel->events.request_activate.listener_list)); + assert(wl_list_empty(&toplevel->events.request_fullscreen.listener_list)); + assert(wl_list_empty(&toplevel->events.request_close.listener_list)); + assert(wl_list_empty(&toplevel->events.set_rectangle.listener_list)); + assert(wl_list_empty(&toplevel->events.destroy.listener_list)); + struct wl_resource *resource, *tmp; wl_resource_for_each_safe(resource, tmp, &toplevel->resources) { zwlr_foreign_toplevel_handle_v1_send_closed(resource); @@ -627,6 +635,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_foreign_toplevel_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -650,6 +661,7 @@ struct wlr_foreign_toplevel_manager_v1 *wlr_foreign_toplevel_manager_v1_create( } wl_signal_init(&manager->events.destroy); + wl_list_init(&manager->resources); wl_list_init(&manager->toplevels); diff --git a/types/wlr_fullscreen_shell_v1.c b/types/wlr_fullscreen_shell_v1.c index d59e94a47..53d8c4e91 100644 --- a/types/wlr_fullscreen_shell_v1.c +++ b/types/wlr_fullscreen_shell_v1.c @@ -109,6 +109,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_fullscreen_shell_v1 *shell = wl_container_of(listener, shell, display_destroy); wl_signal_emit_mutable(&shell->events.destroy, shell); + + assert(wl_list_empty(&shell->events.destroy.listener_list)); + assert(wl_list_empty(&shell->events.present_surface.listener_list)); + wl_list_remove(&shell->display_destroy.link); wl_global_destroy(shell->global); free(shell); diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index 732439de4..087281423 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -215,6 +215,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_gamma_control_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.set_gamma.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -237,6 +241,7 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( wl_signal_init(&manager->events.destroy); wl_signal_init(&manager->events.set_gamma); + wl_list_init(&manager->controls); manager->display_destroy.notify = handle_display_destroy; diff --git a/types/wlr_idle_inhibit_v1.c b/types/wlr_idle_inhibit_v1.c index 93e8e8546..388778800 100644 --- a/types/wlr_idle_inhibit_v1.c +++ b/types/wlr_idle_inhibit_v1.c @@ -34,6 +34,8 @@ static void idle_inhibitor_v1_destroy(struct wlr_idle_inhibitor_v1 *inhibitor) { wl_signal_emit_mutable(&inhibitor->events.destroy, inhibitor->surface); + assert(wl_list_empty(&inhibitor->events.destroy.listener_list)); + wl_resource_set_user_data(inhibitor->resource, NULL); wl_list_remove(&inhibitor->link); wl_list_remove(&inhibitor->surface_destroy.link); @@ -87,6 +89,7 @@ static void manager_handle_create_inhibitor(struct wl_client *client, inhibitor->resource = inhibitor_resource; inhibitor->surface = surface; + wl_signal_init(&inhibitor->events.destroy); inhibitor->surface_destroy.notify = idle_inhibitor_handle_surface_destroy; @@ -113,6 +116,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_idle_inhibit_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_inhibitor.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -140,6 +147,7 @@ struct wlr_idle_inhibit_manager_v1 *wlr_idle_inhibit_v1_create(struct wl_display } wl_list_init(&manager->inhibitors); + wl_signal_init(&manager->events.new_inhibitor); wl_signal_init(&manager->events.destroy); diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index ede2e04d8..8d6301589 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -1,4 +1,4 @@ - +#include #include #include #include "interfaces/wlr_input_device.h" @@ -20,7 +20,7 @@ void wlr_input_device_finish(struct wlr_input_device *wlr_device) { wl_signal_emit_mutable(&wlr_device->events.destroy, wlr_device); - wl_list_remove(&wlr_device->events.destroy.listener_list); + assert(wl_list_empty(&wlr_device->events.destroy.listener_list)); free(wlr_device->name); } diff --git a/types/wlr_input_method_v2.c b/types/wlr_input_method_v2.c index e187ea74c..3804a113a 100644 --- a/types/wlr_input_method_v2.c +++ b/types/wlr_input_method_v2.c @@ -27,6 +27,9 @@ static void popup_surface_destroy(struct wlr_input_popup_surface_v2 *popup_surfa wlr_surface_unmap(popup_surface->surface); wl_signal_emit_mutable(&popup_surface->events.destroy, NULL); + + assert(wl_list_empty(&popup_surface->events.destroy.listener_list)); + wl_list_remove(&popup_surface->link); wl_resource_set_user_data(popup_surface->resource, NULL); free(popup_surface); @@ -54,6 +57,12 @@ static void input_method_destroy(struct wlr_input_method_v2 *input_method) { popup_surface_destroy(popup_surface); } wl_signal_emit_mutable(&input_method->events.destroy, input_method); + + assert(wl_list_empty(&input_method->events.commit.listener_list)); + assert(wl_list_empty(&input_method->events.new_popup_surface.listener_list)); + assert(wl_list_empty(&input_method->events.grab_keyboard.listener_list)); + assert(wl_list_empty(&input_method->events.destroy.listener_list)); + wl_list_remove(wl_resource_get_link(input_method->resource)); wl_list_remove(&input_method->seat_client_destroy.link); wlr_input_method_keyboard_grab_v2_destroy(input_method->keyboard_grab); @@ -263,6 +272,9 @@ void wlr_input_method_keyboard_grab_v2_destroy( return; } wl_signal_emit_mutable(&keyboard_grab->events.destroy, keyboard_grab); + + assert(wl_list_empty(&keyboard_grab->events.destroy.listener_list)); + keyboard_grab->input_method->keyboard_grab = NULL; if (keyboard_grab->keyboard) { wl_list_remove(&keyboard_grab->keyboard_keymap.link); @@ -433,7 +445,9 @@ static void im_grab_keyboard(struct wl_client *client, keyboard_grab->resource = keyboard_grab_resource; keyboard_grab->input_method = input_method; input_method->keyboard_grab = keyboard_grab; + wl_signal_init(&keyboard_grab->events.destroy); + wl_signal_emit_mutable(&input_method->events.grab_keyboard, keyboard_grab); } @@ -544,6 +558,7 @@ static void manager_get_input_method(struct wl_client *client, return; } wl_list_init(&input_method->popup_surfaces); + wl_signal_init(&input_method->events.commit); wl_signal_init(&input_method->events.new_popup_surface); wl_signal_init(&input_method->events.grab_keyboard); @@ -592,6 +607,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_input_method_manager_v2 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.input_method.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -603,8 +622,10 @@ struct wlr_input_method_manager_v2 *wlr_input_method_manager_v2_create( if (!im_manager) { return NULL; } + wl_signal_init(&im_manager->events.input_method); wl_signal_init(&im_manager->events.destroy); + wl_list_init(&im_manager->input_methods); im_manager->global = wl_global_create(display, diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 5eff3ba39..edf0d3ecb 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -171,6 +171,11 @@ void wlr_keyboard_finish(struct wlr_keyboard *kb) { wlr_input_device_finish(&kb->base); + assert(wl_list_empty(&kb->events.key.listener_list)); + assert(wl_list_empty(&kb->events.modifiers.listener_list)); + assert(wl_list_empty(&kb->events.keymap.listener_list)); + assert(wl_list_empty(&kb->events.repeat_info.listener_list)); + keyboard_unset_keymap(kb); } diff --git a/types/wlr_keyboard_group.c b/types/wlr_keyboard_group.c index 25ef66695..734e0b2f3 100644 --- a/types/wlr_keyboard_group.c +++ b/types/wlr_keyboard_group.c @@ -311,7 +311,9 @@ void wlr_keyboard_group_destroy(struct wlr_keyboard_group *group) { wlr_keyboard_group_remove_keyboard(group, device->keyboard); } wlr_keyboard_finish(&group->keyboard); - wl_list_remove(&group->events.enter.listener_list); - wl_list_remove(&group->events.leave.listener_list); + + assert(wl_list_empty(&group->events.enter.listener_list)); + assert(wl_list_empty(&group->events.leave.listener_list)); + free(group); } diff --git a/types/wlr_keyboard_shortcuts_inhibit_v1.c b/types/wlr_keyboard_shortcuts_inhibit_v1.c index 0e4355616..db4f678f7 100644 --- a/types/wlr_keyboard_shortcuts_inhibit_v1.c +++ b/types/wlr_keyboard_shortcuts_inhibit_v1.c @@ -36,6 +36,8 @@ static void keyboard_shortcuts_inhibitor_v1_destroy( wl_signal_emit_mutable(&inhibitor->events.destroy, inhibitor); + assert(wl_list_empty(&inhibitor->events.destroy.listener_list)); + wl_resource_set_user_data(inhibitor->resource, NULL); wl_list_remove(&inhibitor->link); wl_list_remove(&inhibitor->surface_destroy.link); @@ -132,6 +134,7 @@ static void manager_handle_inhibit_shortcuts(struct wl_client *client, inhibitor->surface = surface; inhibitor->seat = seat; inhibitor->active = false; + wl_signal_init(&inhibitor->events.destroy); inhibitor->surface_destroy.notify = @@ -162,6 +165,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_keyboard_shortcuts_inhibit_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_inhibitor.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -191,6 +198,7 @@ wlr_keyboard_shortcuts_inhibit_v1_create(struct wl_display *display) { } wl_list_init(&manager->inhibitors); + wl_signal_init(&manager->events.new_inhibitor); wl_signal_init(&manager->events.destroy); diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c index d4893871c..b6181c6dc 100644 --- a/types/wlr_layer_shell_v1.c +++ b/types/wlr_layer_shell_v1.c @@ -50,6 +50,10 @@ static void layer_surface_destroy(struct wlr_layer_surface_v1 *surface) { layer_surface_reset(surface); wl_signal_emit_mutable(&surface->events.destroy, surface); + + assert(wl_list_empty(&surface->events.destroy.listener_list)); + assert(wl_list_empty(&surface->events.new_popup.listener_list)); + wlr_surface_synced_finish(&surface->synced); wl_resource_set_user_data(surface->resource, NULL); free(surface->namespace); @@ -541,6 +545,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_layer_shell_v1 *layer_shell = wl_container_of(listener, layer_shell, display_destroy); wl_signal_emit_mutable(&layer_shell->events.destroy, layer_shell); + + assert(wl_list_empty(&layer_shell->events.new_surface.listener_list)); + assert(wl_list_empty(&layer_shell->events.destroy.listener_list)); + wl_list_remove(&layer_shell->display_destroy.link); wl_global_destroy(layer_shell->global); free(layer_shell); diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c index 8ccca906a..3165e8805 100644 --- a/types/wlr_linux_dmabuf_v1.c +++ b/types/wlr_linux_dmabuf_v1.c @@ -859,6 +859,8 @@ static const struct wlr_buffer_resource_interface buffer_resource_interface = { static void linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) { wl_signal_emit_mutable(&linux_dmabuf->events.destroy, linux_dmabuf); + assert(wl_list_empty(&linux_dmabuf->events.destroy.listener_list)); + struct wlr_linux_dmabuf_v1_surface *surface, *surface_tmp; wl_list_for_each_safe(surface, surface_tmp, &linux_dmabuf->surfaces, link) { surface_destroy(surface); @@ -958,6 +960,7 @@ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *displa linux_dmabuf->main_device_fd = -1; wl_list_init(&linux_dmabuf->surfaces); + wl_signal_init(&linux_dmabuf->events.destroy); linux_dmabuf->global = wl_global_create(display, &zwp_linux_dmabuf_v1_interface, diff --git a/types/wlr_output_layer.c b/types/wlr_output_layer.c index 7624846f8..068cf58a5 100644 --- a/types/wlr_output_layer.c +++ b/types/wlr_output_layer.c @@ -1,3 +1,4 @@ +#include #include #include @@ -9,6 +10,7 @@ struct wlr_output_layer *wlr_output_layer_create(struct wlr_output *output) { wl_list_insert(&output->layers, &layer->link); wlr_addon_set_init(&layer->addons); + wl_signal_init(&layer->events.feedback); return layer; @@ -20,6 +22,9 @@ void wlr_output_layer_destroy(struct wlr_output_layer *layer) { } wlr_addon_set_finish(&layer->addons); + + assert(wl_list_empty(&layer->events.feedback.listener_list)); + wl_list_remove(&layer->link); free(layer); } diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 853ff5944..ef2751179 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -36,6 +36,9 @@ struct wlr_output_layout *wlr_output_layout_create(struct wl_display *display) { static void output_layout_output_destroy( struct wlr_output_layout_output *l_output) { wl_signal_emit_mutable(&l_output->events.destroy, l_output); + + assert(wl_list_empty(&l_output->events.destroy.listener_list)); + wlr_output_destroy_global(l_output->output); wl_list_remove(&l_output->commit.link); wl_list_remove(&l_output->link); @@ -50,6 +53,10 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) { wl_signal_emit_mutable(&layout->events.destroy, layout); + assert(wl_list_empty(&layout->events.add.listener_list)); + assert(wl_list_empty(&layout->events.change.listener_list)); + assert(wl_list_empty(&layout->events.destroy.listener_list)); + struct wlr_output_layout_output *l_output, *temp; wl_list_for_each_safe(l_output, temp, &layout->outputs, link) { output_layout_output_destroy(l_output); @@ -160,6 +167,7 @@ static struct wlr_output_layout_output *output_layout_output_create( } l_output->layout = layout; l_output->output = output; + wl_signal_init(&l_output->events.destroy); /* diff --git a/types/wlr_output_management_v1.c b/types/wlr_output_management_v1.c index 32f6b4ffe..910bcbe5e 100644 --- a/types/wlr_output_management_v1.c +++ b/types/wlr_output_management_v1.c @@ -647,6 +647,11 @@ static void manager_handle_display_destroy(struct wl_listener *listener, struct wlr_output_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.apply.listener_list)); + assert(wl_list_empty(&manager->events.test.listener_list)); + wl_list_remove(&manager->display_destroy.link); struct wlr_output_head_v1 *head, *tmp; wl_list_for_each_safe(head, tmp, &manager->heads, link) { @@ -666,6 +671,7 @@ struct wlr_output_manager_v1 *wlr_output_manager_v1_create( wl_list_init(&manager->resources); wl_list_init(&manager->heads); + wl_signal_init(&manager->events.destroy); wl_signal_init(&manager->events.apply); wl_signal_init(&manager->events.test); diff --git a/types/wlr_output_power_management_v1.c b/types/wlr_output_power_management_v1.c index 25b92e40d..2a9948393 100644 --- a/types/wlr_output_power_management_v1.c +++ b/types/wlr_output_power_management_v1.c @@ -193,6 +193,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_output_power_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.set_mode.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_global_destroy(manager->global); free(manager); } @@ -214,6 +218,7 @@ struct wlr_output_power_manager_v1 *wlr_output_power_manager_v1_create( wl_signal_init(&manager->events.set_mode); wl_signal_init(&manager->events.destroy); + wl_list_init(&manager->output_powers); manager->display_destroy.notify = handle_display_destroy; diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index e4ee10c8e..e99981907 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -51,6 +51,20 @@ void wlr_pointer_finish(struct wlr_pointer *pointer) { wlr_input_device_finish(&pointer->base); + assert(wl_list_empty(&pointer->events.motion.listener_list)); + assert(wl_list_empty(&pointer->events.motion_absolute.listener_list)); + assert(wl_list_empty(&pointer->events.button.listener_list)); + assert(wl_list_empty(&pointer->events.axis.listener_list)); + assert(wl_list_empty(&pointer->events.frame.listener_list)); + assert(wl_list_empty(&pointer->events.swipe_begin.listener_list)); + assert(wl_list_empty(&pointer->events.swipe_update.listener_list)); + assert(wl_list_empty(&pointer->events.swipe_end.listener_list)); + assert(wl_list_empty(&pointer->events.pinch_begin.listener_list)); + assert(wl_list_empty(&pointer->events.pinch_update.listener_list)); + assert(wl_list_empty(&pointer->events.pinch_end.listener_list)); + assert(wl_list_empty(&pointer->events.hold_begin.listener_list)); + assert(wl_list_empty(&pointer->events.hold_end.listener_list)); + free(pointer->output_name); } diff --git a/types/wlr_pointer_constraints_v1.c b/types/wlr_pointer_constraints_v1.c index 4560c273b..94cb48f24 100644 --- a/types/wlr_pointer_constraints_v1.c +++ b/types/wlr_pointer_constraints_v1.c @@ -47,6 +47,9 @@ static void pointer_constraint_destroy(struct wlr_pointer_constraint_v1 *constra wl_signal_emit_mutable(&constraint->events.destroy, constraint); + assert(wl_list_empty(&constraint->events.set_region.listener_list)); + assert(wl_list_empty(&constraint->events.destroy.listener_list)); + wl_resource_set_user_data(constraint->resource, NULL); wlr_surface_synced_finish(&constraint->synced); wl_list_remove(&constraint->link); @@ -323,6 +326,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_pointer_constraints_v1 *pointer_constraints = wl_container_of(listener, pointer_constraints, display_destroy); wl_signal_emit_mutable(&pointer_constraints->events.destroy, NULL); + + assert(wl_list_empty(&pointer_constraints->events.destroy.listener_list)); + assert(wl_list_empty(&pointer_constraints->events.new_constraint.listener_list)); + wl_list_remove(&pointer_constraints->display_destroy.link); wl_global_destroy(pointer_constraints->global); free(pointer_constraints); diff --git a/types/wlr_pointer_gestures_v1.c b/types/wlr_pointer_gestures_v1.c index ebb1c8689..a027faac9 100644 --- a/types/wlr_pointer_gestures_v1.c +++ b/types/wlr_pointer_gestures_v1.c @@ -397,6 +397,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_pointer_gestures_v1 *gestures = wl_container_of(listener, gestures, display_destroy); wl_signal_emit_mutable(&gestures->events.destroy, NULL); + + assert(wl_list_empty(&gestures->events.destroy.listener_list)); + wl_list_remove(&gestures->display_destroy.link); wl_global_destroy(gestures->global); free(gestures); diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c index 0e5e88ea6..763cae953 100644 --- a/types/wlr_presentation_time.c +++ b/types/wlr_presentation_time.c @@ -166,6 +166,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_presentation *presentation = wl_container_of(listener, presentation, display_destroy); wl_signal_emit_mutable(&presentation->events.destroy, presentation); + + assert(wl_list_empty(&presentation->events.destroy.listener_list)); + wl_list_remove(&presentation->display_destroy.link); wl_global_destroy(presentation->global); free(presentation); diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c index e3212d6fe..1940a2d82 100644 --- a/types/wlr_primary_selection.c +++ b/types/wlr_primary_selection.c @@ -11,6 +11,7 @@ void wlr_primary_selection_source_init( .impl = impl, }; wl_array_init(&source->mime_types); + wl_signal_init(&source->events.destroy); } @@ -22,6 +23,8 @@ void wlr_primary_selection_source_destroy( wl_signal_emit_mutable(&source->events.destroy, source); + assert(wl_list_empty(&source->events.destroy.listener_list)); + char **p; wl_array_for_each(p, &source->mime_types) { free(*p); diff --git a/types/wlr_primary_selection_v1.c b/types/wlr_primary_selection_v1.c index 0a5f0fbdc..fe70b7784 100644 --- a/types/wlr_primary_selection_v1.c +++ b/types/wlr_primary_selection_v1.c @@ -462,6 +462,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { } wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -483,6 +486,7 @@ struct wlr_primary_selection_v1_device_manager * } wl_list_init(&manager->devices); + wl_signal_init(&manager->events.destroy); manager->display_destroy.notify = handle_display_destroy; diff --git a/types/wlr_relative_pointer_v1.c b/types/wlr_relative_pointer_v1.c index 94fb1555e..9f4ab6fd7 100644 --- a/types/wlr_relative_pointer_v1.c +++ b/types/wlr_relative_pointer_v1.c @@ -28,6 +28,8 @@ static struct wlr_relative_pointer_manager_v1 *relative_pointer_manager_from_res static void relative_pointer_destroy(struct wlr_relative_pointer_v1 *relative_pointer) { wl_signal_emit_mutable(&relative_pointer->events.destroy, relative_pointer); + assert(wl_list_empty(&relative_pointer->events.destroy.listener_list)); + wl_list_remove(&relative_pointer->link); wl_list_remove(&relative_pointer->seat_destroy.link); wl_list_remove(&relative_pointer->pointer_destroy.link); @@ -139,6 +141,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_relative_pointer_manager_v1 *manager = wl_container_of(listener, manager, display_destroy_listener); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.new_relative_pointer.listener_list)); + wl_list_remove(&manager->display_destroy_listener.link); wl_global_destroy(manager->global); free(manager); diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index 47cb5a3cf..7cf583b29 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -700,6 +700,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_screencopy_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); diff --git a/types/wlr_security_context_v1.c b/types/wlr_security_context_v1.c index 337114487..da430c012 100644 --- a/types/wlr_security_context_v1.c +++ b/types/wlr_security_context_v1.c @@ -390,6 +390,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_security_context_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + assert(wl_list_empty(&manager->events.destroy.listener_list)); assert(wl_list_empty(&manager->events.commit.listener_list)); @@ -419,6 +420,7 @@ struct wlr_security_context_manager_v1 *wlr_security_context_manager_v1_create( } wl_list_init(&manager->contexts); + wl_signal_init(&manager->events.destroy); wl_signal_init(&manager->events.commit); diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index 3d3d1ff3f..a6f33b469 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -36,6 +36,10 @@ static void server_decoration_handle_request_mode(struct wl_client *client, static void server_decoration_destroy( struct wlr_server_decoration *decoration) { wl_signal_emit_mutable(&decoration->events.destroy, decoration); + + assert(wl_list_empty(&decoration->events.destroy.listener_list)); + assert(wl_list_empty(&decoration->events.mode.listener_list)); + wl_list_remove(&decoration->surface_destroy_listener.link); wl_resource_set_user_data(decoration->resource, NULL); wl_list_remove(&decoration->link); @@ -164,6 +168,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_server_decoration_manager *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_decoration.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -185,6 +193,7 @@ struct wlr_server_decoration_manager *wlr_server_decoration_manager_create( manager->default_mode = ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE; wl_list_init(&manager->resources); wl_list_init(&manager->decorations); + wl_signal_init(&manager->events.new_decoration); wl_signal_init(&manager->events.destroy); diff --git a/types/wlr_subcompositor.c b/types/wlr_subcompositor.c index f0d0827b6..062fa69b8 100644 --- a/types/wlr_subcompositor.c +++ b/types/wlr_subcompositor.c @@ -33,6 +33,8 @@ static void subsurface_destroy(struct wlr_subsurface *subsurface) { wl_signal_emit_mutable(&subsurface->events.destroy, subsurface); + assert(wl_list_empty(&subsurface->events.destroy.listener_list)); + wlr_surface_synced_finish(&subsurface->parent_synced); wl_list_remove(&subsurface->surface_client_commit.link); @@ -406,6 +408,9 @@ static void subcompositor_handle_display_destroy( struct wlr_subcompositor *subcompositor = wl_container_of(listener, subcompositor, display_destroy); wl_signal_emit_mutable(&subcompositor->events.destroy, NULL); + + assert(wl_list_empty(&subcompositor->events.destroy.listener_list)); + wl_list_remove(&subcompositor->display_destroy.link); wl_global_destroy(subcompositor->global); free(subcompositor); diff --git a/types/wlr_switch.c b/types/wlr_switch.c index 93033aaba..439c29333 100644 --- a/types/wlr_switch.c +++ b/types/wlr_switch.c @@ -25,4 +25,6 @@ void wlr_switch_init(struct wlr_switch *switch_device, void wlr_switch_finish(struct wlr_switch *switch_device) { wlr_input_device_finish(&switch_device->base); + + assert(wl_list_empty(&switch_device->events.toggle.listener_list)); } diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index 2c4c04ac3..bfe17e68d 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -33,6 +33,11 @@ void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, void wlr_tablet_pad_finish(struct wlr_tablet_pad *pad) { wlr_input_device_finish(&pad->base); + assert(wl_list_empty(&pad->events.button.listener_list)); + assert(wl_list_empty(&pad->events.ring.listener_list)); + assert(wl_list_empty(&pad->events.strip.listener_list)); + assert(wl_list_empty(&pad->events.attach_tablet.listener_list)); + char **path_ptr; wl_array_for_each(path_ptr, &pad->paths) { free(*path_ptr); diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c index 77f4631e8..2b15f57ee 100644 --- a/types/wlr_tablet_tool.c +++ b/types/wlr_tablet_tool.c @@ -24,12 +24,18 @@ void wlr_tablet_init(struct wlr_tablet *tablet, wl_signal_init(&tablet->events.proximity); wl_signal_init(&tablet->events.tip); wl_signal_init(&tablet->events.button); + wl_array_init(&tablet->paths); } void wlr_tablet_finish(struct wlr_tablet *tablet) { wlr_input_device_finish(&tablet->base); + assert(wl_list_empty(&tablet->events.axis.listener_list)); + assert(wl_list_empty(&tablet->events.proximity.listener_list)); + assert(wl_list_empty(&tablet->events.tip.listener_list)); + assert(wl_list_empty(&tablet->events.button.listener_list)); + char **path_ptr; wl_array_for_each(path_ptr, &tablet->paths) { free(*path_ptr); diff --git a/types/wlr_tearing_control_v1.c b/types/wlr_tearing_control_v1.c index e5a88fec5..6ba0b2740 100644 --- a/types/wlr_tearing_control_v1.c +++ b/types/wlr_tearing_control_v1.c @@ -34,6 +34,9 @@ static void destroy_tearing_hint(struct wlr_tearing_control_v1 *hint) { wl_signal_emit_mutable(&hint->events.destroy, NULL); + assert(wl_list_empty(&hint->events.set_hint.listener_list)); + assert(wl_list_empty(&hint->events.destroy.listener_list)); + wl_list_remove(&hint->link); wl_resource_set_user_data(hint->resource, NULL); @@ -170,6 +173,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { wl_signal_emit_mutable(&manager->events.destroy, NULL); + assert(wl_list_empty(&manager->events.new_object.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + struct wlr_tearing_control_v1 *hint, *tmp; wl_list_for_each_safe(hint, tmp, &manager->surface_hints, link) { destroy_tearing_hint(hint); diff --git a/types/wlr_text_input_v3.c b/types/wlr_text_input_v3.c index 0b05ca656..6c9f07964 100644 --- a/types/wlr_text_input_v3.c +++ b/types/wlr_text_input_v3.c @@ -65,6 +65,12 @@ void wlr_text_input_v3_send_done(struct wlr_text_input_v3 *text_input) { static void wlr_text_input_destroy(struct wlr_text_input_v3 *text_input) { wl_signal_emit_mutable(&text_input->events.destroy, text_input); + + assert(wl_list_empty(&text_input->events.enable.listener_list)); + assert(wl_list_empty(&text_input->events.commit.listener_list)); + assert(wl_list_empty(&text_input->events.disable.listener_list)); + assert(wl_list_empty(&text_input->events.destroy.listener_list)); + text_input_clear_focused_surface(text_input); wl_list_remove(&text_input->seat_destroy.link); // remove from manager.text_inputs @@ -308,6 +314,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_text_input_manager_v3 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.text_input.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -321,6 +331,7 @@ struct wlr_text_input_manager_v3 *wlr_text_input_manager_v3_create( } wl_list_init(&manager->text_inputs); + wl_signal_init(&manager->events.text_input); wl_signal_init(&manager->events.destroy); diff --git a/types/wlr_touch.c b/types/wlr_touch.c index 66b35e544..f8c4175fb 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -30,5 +30,11 @@ void wlr_touch_init(struct wlr_touch *touch, void wlr_touch_finish(struct wlr_touch *touch) { wlr_input_device_finish(&touch->base); + assert(wl_list_empty(&touch->events.down.listener_list)); + assert(wl_list_empty(&touch->events.up.listener_list)); + assert(wl_list_empty(&touch->events.motion.listener_list)); + assert(wl_list_empty(&touch->events.cancel.listener_list)); + assert(wl_list_empty(&touch->events.frame.listener_list)); + free(touch->output_name); } diff --git a/types/wlr_transient_seat_v1.c b/types/wlr_transient_seat_v1.c index 717b36dc0..af8f87ccf 100644 --- a/types/wlr_transient_seat_v1.c +++ b/types/wlr_transient_seat_v1.c @@ -115,6 +115,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_transient_seat_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, NULL); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + assert(wl_list_empty(&manager->events.create_seat.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); diff --git a/types/wlr_viewporter.c b/types/wlr_viewporter.c index 38c204380..4a755113a 100644 --- a/types/wlr_viewporter.c +++ b/types/wlr_viewporter.c @@ -230,6 +230,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_viewporter *viewporter = wl_container_of(listener, viewporter, display_destroy); wl_signal_emit_mutable(&viewporter->events.destroy, NULL); + + assert(wl_list_empty(&viewporter->events.destroy.listener_list)); + wl_global_destroy(viewporter->global); free(viewporter); } diff --git a/types/wlr_virtual_keyboard_v1.c b/types/wlr_virtual_keyboard_v1.c index 8a6d107d5..e7dcb3ec3 100644 --- a/types/wlr_virtual_keyboard_v1.c +++ b/types/wlr_virtual_keyboard_v1.c @@ -209,6 +209,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_virtual_keyboard_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_virtual_keyboard.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); diff --git a/types/wlr_virtual_pointer_v1.c b/types/wlr_virtual_pointer_v1.c index 812e7d565..b867c8fb1 100644 --- a/types/wlr_virtual_pointer_v1.c +++ b/types/wlr_virtual_pointer_v1.c @@ -308,6 +308,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_virtual_pointer_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_virtual_pointer.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); struct wlr_virtual_pointer_v1 *pointer, *pointer_tmp; @@ -329,6 +333,7 @@ struct wlr_virtual_pointer_manager_v1* wlr_virtual_pointer_manager_v1_create( wl_signal_init(&manager->events.new_virtual_pointer); wl_signal_init(&manager->events.destroy); + manager->global = wl_global_create(display, &zwlr_virtual_pointer_manager_v1_interface, 2, manager, virtual_pointer_manager_bind); diff --git a/types/wlr_xdg_activation_v1.c b/types/wlr_xdg_activation_v1.c index 8e0fb0618..4645ccc0e 100644 --- a/types/wlr_xdg_activation_v1.c +++ b/types/wlr_xdg_activation_v1.c @@ -33,6 +33,8 @@ void wlr_xdg_activation_token_v1_destroy( wl_signal_emit_mutable(&token->events.destroy, NULL); + assert(wl_list_empty(&token->events.destroy.listener_list)); + wl_list_remove(&token->link); wl_list_remove(&token->seat_destroy.link); wl_list_remove(&token->surface_destroy.link); @@ -256,6 +258,7 @@ static struct wlr_xdg_activation_token_v1 *activation_token_create( wl_list_init(&token->link); wl_list_init(&token->seat_destroy.link); wl_list_init(&token->surface_destroy.link); + wl_signal_init(&token->events.destroy); token->activation = activation; @@ -340,6 +343,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { wl_container_of(listener, activation, display_destroy); wl_signal_emit_mutable(&activation->events.destroy, NULL); + assert(wl_list_empty(&activation->events.destroy.listener_list)); + assert(wl_list_empty(&activation->events.request_activate.listener_list)); + assert(wl_list_empty(&activation->events.new_token.listener_list)); + struct wlr_xdg_activation_token_v1 *token, *token_tmp; wl_list_for_each_safe(token, token_tmp, &activation->tokens, link) { wlr_xdg_activation_token_v1_destroy(token); @@ -359,6 +366,7 @@ struct wlr_xdg_activation_v1 *wlr_xdg_activation_v1_create( activation->token_timeout_msec = 30000; // 30s wl_list_init(&activation->tokens); + wl_signal_init(&activation->events.destroy); wl_signal_init(&activation->events.request_activate); wl_signal_init(&activation->events.new_token); diff --git a/types/wlr_xdg_decoration_v1.c b/types/wlr_xdg_decoration_v1.c index d16ac7c5a..4194942a2 100644 --- a/types/wlr_xdg_decoration_v1.c +++ b/types/wlr_xdg_decoration_v1.c @@ -62,6 +62,10 @@ static void toplevel_decoration_handle_resource_destroy( struct wlr_xdg_toplevel_decoration_v1 *decoration = toplevel_decoration_from_resource(resource); wl_signal_emit_mutable(&decoration->events.destroy, decoration); + + assert(wl_list_empty(&decoration->events.destroy.listener_list)); + assert(wl_list_empty(&decoration->events.request_mode.listener_list)); + wlr_surface_synced_finish(&decoration->synced); wl_list_remove(&decoration->toplevel_destroy.link); wl_list_remove(&decoration->surface_configure.link); @@ -217,6 +221,7 @@ static void decoration_manager_handle_get_toplevel_decoration( decoration->resource); wl_list_init(&decoration->configure_list); + wl_signal_init(&decoration->events.destroy); wl_signal_init(&decoration->events.request_mode); @@ -256,6 +261,10 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xdg_decoration_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.new_toplevel_decoration.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); free(manager); @@ -275,6 +284,7 @@ struct wlr_xdg_decoration_manager_v1 * return NULL; } wl_list_init(&manager->decorations); + wl_signal_init(&manager->events.new_toplevel_decoration); wl_signal_init(&manager->events.destroy); diff --git a/types/wlr_xdg_dialog_v1.c b/types/wlr_xdg_dialog_v1.c index f1eac0207..dc9cb2470 100644 --- a/types/wlr_xdg_dialog_v1.c +++ b/types/wlr_xdg_dialog_v1.c @@ -76,6 +76,9 @@ static void dialog_destroy(struct wlr_xdg_dialog_v1 *dialog) { wl_signal_emit_mutable(&dialog->events.destroy, NULL); + assert(wl_list_empty(&dialog->events.destroy.listener_list)); + assert(wl_list_empty(&dialog->events.set_modal.listener_list)); + wlr_addon_finish(&dialog->surface_addon); wl_list_remove(&dialog->xdg_toplevel_destroy.link); @@ -154,6 +157,9 @@ static void xdg_wm_dialog_handle_display_destroy(struct wl_listener *listener, v struct wlr_xdg_wm_dialog_v1 *wm = wl_container_of(listener, wm, display_destroy); wl_signal_emit_mutable(&wm->events.destroy, NULL); + assert(wl_list_empty(&wm->events.destroy.listener_list)); + assert(wl_list_empty(&wm->events.new_dialog.listener_list)); + wl_list_remove(&wm->display_destroy.link); wl_global_destroy(wm->global); free(wm); diff --git a/types/wlr_xdg_foreign_registry.c b/types/wlr_xdg_foreign_registry.c index c27d84069..ef9c3135c 100644 --- a/types/wlr_xdg_foreign_registry.c +++ b/types/wlr_xdg_foreign_registry.c @@ -17,6 +17,7 @@ bool wlr_xdg_foreign_exported_init( wl_list_insert(®istry->exported_surfaces, &exported->link); wl_signal_init(&exported->events.destroy); + return true; } @@ -38,6 +39,9 @@ struct wlr_xdg_foreign_exported *wlr_xdg_foreign_registry_find_by_handle( void wlr_xdg_foreign_exported_finish(struct wlr_xdg_foreign_exported *surface) { wl_signal_emit_mutable(&surface->events.destroy, NULL); + + assert(wl_list_empty(&surface->events.destroy.listener_list)); + surface->registry = NULL; wl_list_remove(&surface->link); wl_list_init(&surface->link); @@ -50,6 +54,8 @@ static void foreign_registry_handle_display_destroy(struct wl_listener *listener wl_signal_emit_mutable(®istry->events.destroy, NULL); + assert(wl_list_empty(®istry->events.destroy.listener_list)); + // Implementations are supposed to remove all surfaces assert(wl_list_empty(®istry->exported_surfaces)); free(registry); @@ -67,6 +73,8 @@ struct wlr_xdg_foreign_registry *wlr_xdg_foreign_registry_create( wl_display_add_destroy_listener(display, ®istry->display_destroy); wl_list_init(®istry->exported_surfaces); + wl_signal_init(®istry->events.destroy); + return registry; } diff --git a/types/wlr_xdg_foreign_v1.c b/types/wlr_xdg_foreign_v1.c index 9fb2b235f..1c5983951 100644 --- a/types/wlr_xdg_foreign_v1.c +++ b/types/wlr_xdg_foreign_v1.c @@ -345,6 +345,9 @@ static void xdg_foreign_destroy(struct wlr_xdg_foreign_v1 *foreign) { } wl_signal_emit_mutable(&foreign->events.destroy, NULL); + + assert(wl_list_empty(&foreign->events.destroy.listener_list)); + wl_list_remove(&foreign->foreign_registry_destroy.link); wl_list_remove(&foreign->display_destroy.link); @@ -395,6 +398,7 @@ struct wlr_xdg_foreign_v1 *wlr_xdg_foreign_v1_create( foreign->registry = registry; wl_signal_init(&foreign->events.destroy); + wl_list_init(&foreign->exporter.objects); wl_list_init(&foreign->importer.objects); diff --git a/types/wlr_xdg_foreign_v2.c b/types/wlr_xdg_foreign_v2.c index eef93175e..8ea2af2a8 100644 --- a/types/wlr_xdg_foreign_v2.c +++ b/types/wlr_xdg_foreign_v2.c @@ -348,6 +348,9 @@ static void xdg_foreign_destroy(struct wlr_xdg_foreign_v2 *foreign) { } wl_signal_emit_mutable(&foreign->events.destroy, NULL); + + assert(wl_list_empty(&foreign->events.destroy.listener_list)); + wl_list_remove(&foreign->foreign_registry_destroy.link); wl_list_remove(&foreign->display_destroy.link); @@ -398,6 +401,7 @@ struct wlr_xdg_foreign_v2 *wlr_xdg_foreign_v2_create( foreign->registry = registry; wl_signal_init(&foreign->events.destroy); + wl_list_init(&foreign->exporter.objects); wl_list_init(&foreign->importer.objects); diff --git a/types/wlr_xdg_output_v1.c b/types/wlr_xdg_output_v1.c index 895a0f0aa..262123987 100644 --- a/types/wlr_xdg_output_v1.c +++ b/types/wlr_xdg_output_v1.c @@ -140,7 +140,7 @@ static void output_manager_handle_get_xdg_output(struct wl_client *client, output_send_details(xdg_output, xdg_output_resource); uint32_t wl_version = wl_resource_get_version(output_resource); - if (wl_version >= WL_OUTPUT_DONE_SINCE_VERSION && + if (wl_version >= WL_OUTPUT_DONE_SINCE_VERSION && xdg_version >= OUTPUT_DONE_DEPRECATED_SINCE_VERSION) { wl_output_send_done(output_resource); } @@ -234,7 +234,11 @@ static void manager_destroy(struct wlr_xdg_output_manager_v1 *manager) { wl_list_for_each_safe(output, tmp, &manager->outputs, link) { output_destroy(output); } + wl_signal_emit_mutable(&manager->events.destroy, manager); + + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_list_remove(&manager->layout_add.link); wl_list_remove(&manager->layout_change.link); diff --git a/types/wlr_xdg_system_bell_v1.c b/types/wlr_xdg_system_bell_v1.c index 8a8850540..3cabf6559 100644 --- a/types/wlr_xdg_system_bell_v1.c +++ b/types/wlr_xdg_system_bell_v1.c @@ -52,6 +52,10 @@ static void bell_bind(struct wl_client *client, void *data, static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xdg_system_bell_v1 *bell = wl_container_of(listener, bell, display_destroy); wl_signal_emit_mutable(&bell->events.destroy, NULL); + + assert(wl_list_empty(&bell->events.destroy.listener_list)); + assert(wl_list_empty(&bell->events.ring.listener_list)); + wl_list_remove(&bell->display_destroy.link); wl_global_destroy(bell->global); free(bell); diff --git a/types/wlr_xdg_toplevel_icon_v1.c b/types/wlr_xdg_toplevel_icon_v1.c index 0995e6d1c..5927b8168 100644 --- a/types/wlr_xdg_toplevel_icon_v1.c +++ b/types/wlr_xdg_toplevel_icon_v1.c @@ -229,6 +229,9 @@ static void manager_handle_display_destroy(struct wl_listener *listener, void *d wl_signal_emit_mutable(&manager->events.destroy, NULL); + assert(wl_list_empty(&manager->events.set_icon.listener_list)); + assert(wl_list_empty(&manager->events.destroy.listener_list)); + wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index df1e75de3..25c07c8c5 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -467,6 +467,9 @@ void destroy_xdg_popup(struct wlr_xdg_popup *popup) { wl_signal_emit_mutable(&popup->events.destroy, NULL); + assert(wl_list_empty(&popup->events.destroy.listener_list)); + assert(wl_list_empty(&popup->events.reposition.listener_list)); + wlr_surface_synced_finish(&popup->synced); popup->base->popup = NULL; wl_list_remove(&popup->link); diff --git a/types/xdg_shell/wlr_xdg_shell.c b/types/xdg_shell/wlr_xdg_shell.c index 3baea04eb..0cbadc271 100644 --- a/types/xdg_shell/wlr_xdg_shell.c +++ b/types/xdg_shell/wlr_xdg_shell.c @@ -129,6 +129,12 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xdg_shell *xdg_shell = wl_container_of(listener, xdg_shell, display_destroy); wl_signal_emit_mutable(&xdg_shell->events.destroy, xdg_shell); + + assert(wl_list_empty(&xdg_shell->events.new_surface.listener_list)); + assert(wl_list_empty(&xdg_shell->events.new_toplevel.listener_list)); + assert(wl_list_empty(&xdg_shell->events.new_popup.listener_list)); + assert(wl_list_empty(&xdg_shell->events.destroy.listener_list)); + wl_list_remove(&xdg_shell->display_destroy.link); wl_global_destroy(xdg_shell->global); free(xdg_shell); diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c index 97daa0d30..a752ba316 100644 --- a/types/xdg_shell/wlr_xdg_surface.c +++ b/types/xdg_shell/wlr_xdg_surface.c @@ -523,6 +523,12 @@ void destroy_xdg_surface(struct wlr_xdg_surface *surface) { wl_signal_emit_mutable(&surface->events.destroy, NULL); + assert(wl_list_empty(&surface->events.destroy.listener_list)); + assert(wl_list_empty(&surface->events.ping_timeout.listener_list)); + assert(wl_list_empty(&surface->events.new_popup.listener_list)); + assert(wl_list_empty(&surface->events.configure.listener_list)); + assert(wl_list_empty(&surface->events.ack_configure.listener_list)); + wl_list_remove(&surface->link); wlr_surface_synced_finish(&surface->synced); wl_resource_set_user_data(surface->resource, NULL); diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index bfb583bcc..f7bc52cc1 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -525,6 +525,17 @@ void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) { wl_signal_emit_mutable(&toplevel->events.destroy, NULL); + assert(wl_list_empty(&toplevel->events.destroy.listener_list)); + assert(wl_list_empty(&toplevel->events.request_maximize.listener_list)); + assert(wl_list_empty(&toplevel->events.request_fullscreen.listener_list)); + assert(wl_list_empty(&toplevel->events.request_minimize.listener_list)); + assert(wl_list_empty(&toplevel->events.request_move.listener_list)); + assert(wl_list_empty(&toplevel->events.request_resize.listener_list)); + assert(wl_list_empty(&toplevel->events.request_show_window_menu.listener_list)); + assert(wl_list_empty(&toplevel->events.set_parent.listener_list)); + assert(wl_list_empty(&toplevel->events.set_title.listener_list)); + assert(wl_list_empty(&toplevel->events.set_app_id.listener_list)); + wlr_surface_synced_finish(&toplevel->synced); toplevel->base->toplevel = NULL; wl_resource_set_user_data(toplevel->resource, NULL); diff --git a/xwayland/server.c b/xwayland/server.c index 417bbe54b..0e8ad44fe 100644 --- a/xwayland/server.c +++ b/xwayland/server.c @@ -455,7 +455,13 @@ void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server) { } server_finish_process(server); server_finish_display(server); + wl_signal_emit_mutable(&server->events.destroy, NULL); + + assert(wl_list_empty(&server->events.start.listener_list)); + assert(wl_list_empty(&server->events.ready.listener_list)); + assert(wl_list_empty(&server->events.destroy.listener_list)); + free(server); } diff --git a/xwayland/shell.c b/xwayland/shell.c index 1f7e11aff..f048eb627 100644 --- a/xwayland/shell.c +++ b/xwayland/shell.c @@ -178,6 +178,7 @@ struct wlr_xwayland_shell_v1 *wlr_xwayland_shell_v1_create( } wl_list_init(&shell->surfaces); + wl_signal_init(&shell->events.new_surface); wl_signal_init(&shell->events.destroy); @@ -196,6 +197,9 @@ void wlr_xwayland_shell_v1_destroy(struct wlr_xwayland_shell_v1 *shell) { wl_signal_emit_mutable(&shell->events.destroy, NULL); + assert(wl_list_empty(&shell->events.new_surface.listener_list)); + assert(wl_list_empty(&shell->events.destroy.listener_list)); + struct wlr_xwayland_surface_v1 *xwl_surface, *tmp; wl_list_for_each_safe(xwl_surface, tmp, &shell->surfaces, link) { xwl_surface_destroy(xwl_surface); diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 7fbc33ce1..7cef4cc8f 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -81,6 +81,11 @@ void wlr_xwayland_destroy(struct wlr_xwayland *xwayland) { wl_signal_emit_mutable(&xwayland->events.destroy, NULL); + assert(wl_list_empty(&xwayland->events.destroy.listener_list)); + assert(wl_list_empty(&xwayland->events.new_surface.listener_list)); + assert(wl_list_empty(&xwayland->events.ready.listener_list)); + assert(wl_list_empty(&xwayland->events.remove_startup_info.listener_list)); + wl_list_remove(&xwayland->server_destroy.link); wl_list_remove(&xwayland->server_start.link); wl_list_remove(&xwayland->server_ready.link); diff --git a/xwayland/xwm.c b/xwayland/xwm.c index e77ad1a11..08faed9b6 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -209,6 +209,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create( wl_list_init(&surface->stack_link); wl_list_init(&surface->parent_link); wl_list_init(&surface->unpaired_link); + wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.request_configure); wl_signal_init(&surface->events.request_move); @@ -569,6 +570,40 @@ static void xwayland_surface_destroy(struct wlr_xwayland_surface *xsurface) { wl_signal_emit_mutable(&xsurface->events.destroy, NULL); + assert(wl_list_empty(&xsurface->events.destroy.listener_list)); + assert(wl_list_empty(&xsurface->events.request_configure.listener_list)); + assert(wl_list_empty(&xsurface->events.request_move.listener_list)); + assert(wl_list_empty(&xsurface->events.request_resize.listener_list)); + assert(wl_list_empty(&xsurface->events.request_minimize.listener_list)); + assert(wl_list_empty(&xsurface->events.request_maximize.listener_list)); + assert(wl_list_empty(&xsurface->events.request_fullscreen.listener_list)); + assert(wl_list_empty(&xsurface->events.request_activate.listener_list)); + assert(wl_list_empty(&xsurface->events.request_close.listener_list)); + assert(wl_list_empty(&xsurface->events.request_sticky.listener_list)); + assert(wl_list_empty(&xsurface->events.request_shaded.listener_list)); + assert(wl_list_empty(&xsurface->events.request_skip_taskbar.listener_list)); + assert(wl_list_empty(&xsurface->events.request_skip_pager.listener_list)); + assert(wl_list_empty(&xsurface->events.request_above.listener_list)); + assert(wl_list_empty(&xsurface->events.request_below.listener_list)); + assert(wl_list_empty(&xsurface->events.request_demands_attention.listener_list)); + assert(wl_list_empty(&xsurface->events.associate.listener_list)); + assert(wl_list_empty(&xsurface->events.dissociate.listener_list)); + assert(wl_list_empty(&xsurface->events.set_class.listener_list)); + assert(wl_list_empty(&xsurface->events.set_role.listener_list)); + assert(wl_list_empty(&xsurface->events.set_title.listener_list)); + assert(wl_list_empty(&xsurface->events.set_parent.listener_list)); + assert(wl_list_empty(&xsurface->events.set_startup_id.listener_list)); + assert(wl_list_empty(&xsurface->events.set_window_type.listener_list)); + assert(wl_list_empty(&xsurface->events.set_hints.listener_list)); + assert(wl_list_empty(&xsurface->events.set_decorations.listener_list)); + assert(wl_list_empty(&xsurface->events.set_strut_partial.listener_list)); + assert(wl_list_empty(&xsurface->events.set_override_redirect.listener_list)); + assert(wl_list_empty(&xsurface->events.set_geometry.listener_list)); + assert(wl_list_empty(&xsurface->events.focus_in.listener_list)); + assert(wl_list_empty(&xsurface->events.grab_focus.listener_list)); + assert(wl_list_empty(&xsurface->events.map_request.listener_list)); + assert(wl_list_empty(&xsurface->events.ping_timeout.listener_list)); + if (xsurface == xsurface->xwm->focus_surface) { xwm_surface_activate(xsurface->xwm, NULL); }