aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-12-27 15:26:04 +0100
committerSimon Ser <contact@emersion.fr>2021-04-27 09:11:44 +0200
commitc49ea9ef4f1da9c6d5f6004c94fd4a14926ff19e (patch)
treec8a3dd9b84b5b4969b3eff5f1d80dd9ab513eb1b /backend
parente804de923d68499013bafad813607153bd202522 (diff)
backend/drm: destroy when parent is destroyed
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/backend.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index e09efb12..25d9995a 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -50,6 +50,7 @@ static void backend_destroy(struct wlr_backend *backend) {
wl_list_remove(&drm->display_destroy.link);
wl_list_remove(&drm->session_destroy.link);
wl_list_remove(&drm->session_active.link);
+ wl_list_remove(&drm->parent_destroy.link);
wl_list_remove(&drm->dev_change.link);
finish_drm_resources(drm);
@@ -144,6 +145,12 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
backend_destroy(&drm->backend);
}
+static void handle_parent_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_drm_backend *drm =
+ wl_container_of(listener, drm, parent_destroy);
+ backend_destroy(&drm->backend);
+}
+
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
struct wlr_session *session, struct wlr_device *dev,
struct wlr_backend *parent) {
@@ -169,16 +176,22 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
drm->dev = dev;
drm->fd = dev->fd;
drm->name = name;
+
if (parent != NULL) {
drm->parent = get_drm_backend_from_backend(parent);
+
+ drm->parent_destroy.notify = handle_parent_destroy;
+ wl_signal_add(&parent->events.destroy, &drm->parent_destroy);
+ } else {
+ wl_list_init(&drm->parent_destroy.link);
}
drm->dev_change.notify = handle_dev_change;
wl_signal_add(&dev->events.change, &drm->dev_change);
drm->display = display;
- struct wl_event_loop *event_loop = wl_display_get_event_loop(display);
+ struct wl_event_loop *event_loop = wl_display_get_event_loop(display);
drm->drm_event = wl_event_loop_add_fd(event_loop, drm->fd,
WL_EVENT_READABLE, handle_drm_event, NULL);
if (!drm->drm_event) {