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 <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2022-03-25 15:12:01 +01:00 committed by Derek Foreman
parent 281aa0a4d7
commit baaef12432

View file

@ -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);