aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-29 00:07:31 +0200
committerKenny Levinsen <kl@kl.wtf>2021-05-21 22:13:54 +0200
commit7ec5bf6b10d2a7e1d9cdfdfeed44ac6db8bdcc99 (patch)
tree4bd0b074f7e87e3b5ef55dd2c79cafb65f2407e7
parentbeae3018cbbbbb566e964de63cf04e405b7d8ba5 (diff)
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.
-rw-r--r--backend/backend.c5
-rw-r--r--backend/drm/backend.c2
-rw-r--r--backend/headless/backend.c2
-rw-r--r--backend/libinput/backend.c2
-rw-r--r--backend/multi/backend.c2
-rw-r--r--backend/noop/backend.c2
-rw-r--r--backend/wayland/backend.c2
-rw-r--r--backend/x11/backend.c2
-rw-r--r--include/wlr/backend/interface.h4
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 <wlr/util/log.h>
#include "backend/backend.h"
#include "backend/multi.h"
+#include "util/signal.h"
#if WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
@@ -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