From 7ec5bf6b10d2a7e1d9cdfdfeed44ac6db8bdcc99 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 29 Apr 2021 00:07:31 +0200 Subject: [PATCH] backend: introduce wlr_backend_finish This new functions cleans up the common backend state. While this currently only emits the destroy signal, this will also clean up the renderer and allocator in upcoming patches. --- backend/backend.c | 5 +++++ backend/drm/backend.c | 2 +- backend/headless/backend.c | 2 +- backend/libinput/backend.c | 2 +- backend/multi/backend.c | 2 +- backend/noop/backend.c | 2 +- backend/wayland/backend.c | 2 +- backend/x11/backend.c | 2 +- include/wlr/backend/interface.h | 4 ++++ 9 files changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/backend.c b/backend/backend.c index 11845437..503b6b7d 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -18,6 +18,7 @@ #include #include "backend/backend.h" #include "backend/multi.h" +#include "util/signal.h" #if WLR_HAS_X11_BACKEND #include @@ -32,6 +33,10 @@ void wlr_backend_init(struct wlr_backend *backend, wl_signal_init(&backend->events.new_output); } +void wlr_backend_finish(struct wlr_backend *backend) { + wlr_signal_emit_safe(&backend->events.destroy, backend); +} + bool wlr_backend_start(struct wlr_backend *backend) { if (backend->impl->start) { return backend->impl->start(backend); diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 17387423..2caf76bd 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -41,7 +41,7 @@ static void backend_destroy(struct wlr_backend *backend) { destroy_drm_connector(conn); } - wlr_signal_emit_safe(&backend->events.destroy, backend); + wlr_backend_finish(backend); struct wlr_drm_fb *fb, *fb_tmp; wl_list_for_each_safe(fb, fb_tmp, &drm->fbs, link) { diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 2617b812..875eb768 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -67,7 +67,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { wlr_input_device_destroy(&input_device->wlr_input_device); } - wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); + wlr_backend_finish(wlr_backend); free(backend->format); diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index a9150558..d57f129f 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -150,7 +150,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { free(wlr_devices); } - wlr_signal_emit_safe(&wlr_backend->events.destroy, wlr_backend); + wlr_backend_finish(wlr_backend); wl_list_remove(&backend->display_destroy.link); wl_list_remove(&backend->session_destroy.link); diff --git a/backend/multi/backend.c b/backend/multi/backend.c index e9ed74ec..7c74959e 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -58,7 +58,7 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) { } // Destroy this backend only after removing all sub-backends - wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); + wlr_backend_finish(wlr_backend); free(backend); } diff --git a/backend/noop/backend.c b/backend/noop/backend.c index 67744262..7bdda051 100644 --- a/backend/noop/backend.c +++ b/backend/noop/backend.c @@ -37,7 +37,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { wlr_output_destroy(&output->wlr_output); } - wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); + wlr_backend_finish(wlr_backend); wl_list_remove(&backend->display_destroy.link); diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index e05a13a0..0365aab2 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -309,7 +309,7 @@ static void backend_destroy(struct wlr_backend *backend) { wlr_input_device_destroy(input_device); } - wlr_signal_emit_safe(&wl->backend.events.destroy, &wl->backend); + wlr_backend_finish(backend); wl_list_remove(&wl->local_display_destroy.link); diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 8999912d..17b8b7c0 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -191,7 +191,7 @@ static void backend_destroy(struct wlr_backend *backend) { wlr_input_device_destroy(&x11->keyboard_dev); - wlr_signal_emit_safe(&backend->events.destroy, backend); + wlr_backend_finish(backend); if (x11->event_source) { wl_event_source_remove(x11->event_source); diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index feed8d2d..529f8f87 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -29,5 +29,9 @@ struct wlr_backend_impl { */ void wlr_backend_init(struct wlr_backend *backend, const struct wlr_backend_impl *impl); +/** + * Emit the destroy event and clean up common backend state. + */ +void wlr_backend_finish(struct wlr_backend *backend); #endif