aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-12-14 14:37:43 -0500
committerGitHub <noreply@github.com>2017-12-14 14:37:43 -0500
commit46ac8e1243d3d32c656b09e641f8e9732035f635 (patch)
tree66bcfa4057175e46509f77537d22379075308165 /backend/drm
parenta9fb071d49b244b72846b384a9e2ef2d9b03a05f (diff)
parent75ef7860bbc3017bbe8e176138cac71da0127711 (diff)
Merge pull request #468 from emersion/display-destroy
Use destroy listeners on wl_display
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/backend.c19
-rw-r--r--backend/drm/renderer.c4
2 files changed, 19 insertions, 4 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:
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 87064914..8a8d7d1f 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -39,7 +39,7 @@ bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
return true;
error_egl:
- wlr_egl_free(&renderer->egl);
+ wlr_egl_finish(&renderer->egl);
error_gbm:
gbm_device_destroy(renderer->gbm);
return false;
@@ -51,7 +51,7 @@ void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) {
}
wlr_renderer_destroy(renderer->wlr_rend);
- wlr_egl_free(&renderer->egl);
+ wlr_egl_finish(&renderer->egl);
gbm_device_destroy(renderer->gbm);
}