From baaef12432529819b1473231473fba676bec37fa Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Fri, 25 Mar 2022 15:12:01 +0100
Subject: [PATCH] backend-headless: enable multi-backend support
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine whether the backend is capable of being loaded simultaneously
with other backends.
The headless backend can only be loaded as primary backend.
Signed-off-by: Philipp Zabel
---
libweston/backend-headless/headless.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c
index 92fe26a5..fb757be6 100644
--- a/libweston/backend-headless/headless.c
+++ b/libweston/backend-headless/headless.c
@@ -503,6 +503,8 @@ headless_destroy(struct weston_backend *backend)
struct weston_compositor *ec = b->compositor;
struct weston_head *base, *next;
+ wl_list_remove(&b->base.link);
+
wl_list_for_each_safe(base, next, &ec->head_list, compositor_link) {
if (to_headless_head(base))
headless_head_destroy(base);
@@ -537,7 +539,7 @@ headless_backend_create(struct weston_compositor *compositor,
return NULL;
b->compositor = compositor;
- compositor->backend = &b->base;
+ wl_list_insert(&compositor->backend_list, &b->base.link);
b->base.supported_presentation_clocks =
WESTON_PRESENTATION_CLOCKS_SOFTWARE;
@@ -621,6 +623,7 @@ err_input:
if (b->theme)
theme_destroy(b->theme);
err_free:
+ wl_list_remove(&b->base.link);
free(b);
return NULL;
}
@@ -644,6 +647,11 @@ weston_backend_init(struct weston_compositor *compositor,
return -1;
}
+ if (compositor->renderer) {
+ weston_log("headless backend must be the primary backend\n");
+ return -1;
+ }
+
config_init_to_defaults(&config);
memcpy(&config, config_base, config_base->struct_size);