diff options
Diffstat (limited to 'backend/backend.c')
-rw-r--r-- | backend/backend.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/backend/backend.c b/backend/backend.c index 00d77cd2..13583bba 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -209,6 +209,21 @@ static size_t parse_outputs_env(const char *name) { return outputs; } +static struct wlr_backend *ensure_backend_renderer_and_allocator( + struct wlr_backend *backend) { + struct wlr_renderer *renderer = wlr_backend_get_renderer(backend); + if (renderer == NULL) { + wlr_backend_destroy(backend); + return NULL; + } + struct wlr_allocator *allocator = backend_get_allocator(backend); + if (allocator == NULL) { + wlr_backend_destroy(backend); + return NULL; + } + return backend; +} + static struct wlr_backend *attempt_wl_backend(struct wl_display *display) { struct wlr_backend *backend = wlr_wl_backend_create(display, NULL); if (backend == NULL) { @@ -220,7 +235,7 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display) { wlr_wl_output_create(backend); } - return backend; + return ensure_backend_renderer_and_allocator(backend); } #if WLR_HAS_X11_BACKEND @@ -236,7 +251,7 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display, wlr_x11_output_create(backend); } - return backend; + return ensure_backend_renderer_and_allocator(backend); } #endif @@ -252,7 +267,7 @@ static struct wlr_backend *attempt_headless_backend( wlr_headless_add_output(backend, 1280, 720); } - return backend; + return ensure_backend_renderer_and_allocator(backend); } static struct wlr_backend *attempt_noop_backend(struct wl_display *display) { @@ -297,7 +312,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display, wlr_multi_backend_add(backend, drm); } - return primary_drm; + return ensure_backend_renderer_and_allocator(primary_drm); } #endif |