aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/drm/backend.c')
-rw-r--r--backend/drm/backend.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 87a4f708..6be5e5d5 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -34,6 +34,10 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) {
wlr_output_destroy(&conn->output);
}
+ wl_list_remove(&drm->display_destroy.link);
+ wl_list_remove(&drm->session_signal.link);
+ wl_list_remove(&drm->drm_invalidated.link);
+
wlr_drm_resources_free(drm);
wlr_drm_renderer_finish(&drm->renderer);
wlr_session_close_file(drm->session, drm->fd);
@@ -57,7 +61,8 @@ bool wlr_backend_is_drm(struct wlr_backend *b) {
}
static void session_signal(struct wl_listener *listener, void *data) {
- struct wlr_drm_backend *drm = wl_container_of(listener, drm, session_signal);
+ struct wlr_drm_backend *drm =
+ wl_container_of(listener, drm, session_signal);
struct wlr_session *session = data;
if (session->active) {
@@ -84,7 +89,8 @@ static void session_signal(struct wl_listener *listener, void *data) {
}
static void drm_invalidated(struct wl_listener *listener, void *data) {
- struct wlr_drm_backend *drm = wl_container_of(listener, drm, drm_invalidated);
+ struct wlr_drm_backend *drm =
+ wl_container_of(listener, drm, drm_invalidated);
char *name = drmGetDeviceNameFromFd2(drm->fd);
wlr_log(L_DEBUG, "%s invalidated", name);
@@ -93,6 +99,12 @@ static void drm_invalidated(struct wl_listener *listener, void *data) {
wlr_drm_scan_connectors(drm);
}
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_drm_backend *drm =
+ wl_container_of(listener, drm, display_destroy);
+ wlr_drm_backend_destroy(&drm->backend);
+}
+
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, int gpu_fd, struct wlr_backend *parent) {
assert(display && session && gpu_fd >= 0);
@@ -150,6 +162,9 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
wlr_log(L_INFO, "Failed to bind egl/wl display: %s", egl_error());
}
+ drm->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &drm->display_destroy);
+
return &drm->backend;
error_event: