diff options
author | Simon Ser <contact@emersion.fr> | 2020-05-02 16:44:34 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-05-02 19:36:03 +0200 |
commit | 46c83cbf3daf6c38c70d0dcb5492e164b6c8ab29 (patch) | |
tree | b0e14258c677fb5d5ea7ca9d738419b28c2bf596 /backend/headless | |
parent | 7720ce7827e8bdaaf42f72fb29ecf91a2d3c2294 (diff) |
backend/headless: handle renderer destroy
When the headless backend uses an already-existing renderer, it doesn't
have ownership over the renderer. When the renderer is destroyed, the
headless backend needs to destroy itself.
Diffstat (limited to 'backend/headless')
-rw-r--r-- | backend/headless/backend.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 8eadd3b7..7758ece4 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -47,6 +47,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { } wl_list_remove(&backend->display_destroy.link); + wl_list_remove(&backend->renderer_destroy.link); struct wlr_headless_output *output, *output_tmp; wl_list_for_each_safe(output, output_tmp, &backend->outputs, link) { @@ -61,8 +62,8 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); - wlr_renderer_destroy(backend->renderer); if (backend->egl == &backend->priv_egl) { + wlr_renderer_destroy(backend->renderer); wlr_egl_finish(&backend->priv_egl); } free(backend); @@ -87,6 +88,12 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { backend_destroy(&backend->backend); } +static void handle_renderer_destroy(struct wl_listener *listener, void *data) { + struct wlr_headless_backend *backend = + wl_container_of(listener, backend, renderer_destroy); + backend_destroy(&backend->backend); +} + static bool backend_init(struct wlr_headless_backend *backend, struct wl_display *display, struct wlr_renderer *renderer) { wlr_backend_init(&backend->backend, &backend_impl); @@ -112,6 +119,8 @@ static bool backend_init(struct wlr_headless_backend *backend, backend->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &backend->display_destroy); + wl_list_init(&backend->renderer_destroy.link); + return true; } @@ -173,6 +182,9 @@ struct wlr_backend *wlr_headless_backend_create_with_renderer( return NULL; } + backend->renderer_destroy.notify = handle_renderer_destroy; + wl_signal_add(&renderer->events.destroy, &backend->renderer_destroy); + return &backend->backend; } |