From 4938f8f6e518bd27544f12c6b895c63ea112a887 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 24 Mar 2021 09:08:20 +0100 Subject: [PATCH] compositor: stop creating outputs without head To support heterogeneous outputs, the output must be created by the same backend as the head(s) it is created for. Solve this by always creating an output with a first head to attach that determines the backend to use. Skip already attached first heads in drm_try_attach(). See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268 Signed-off-by: Philipp Zabel --- compositor/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 747f0b75..cbbcee1f 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -2152,7 +2152,9 @@ wet_output_handle_destroy(struct wl_listener *listener, void *data) } static struct wet_output * -wet_layoutput_create_output(struct wet_layoutput *lo, const char *name) +wet_layoutput_create_output_with_head(struct wet_layoutput *lo, + const char *name, + struct weston_head *head) { struct wet_output *output; @@ -2162,7 +2164,7 @@ wet_layoutput_create_output(struct wet_layoutput *lo, const char *name) output->output = weston_compositor_create_output(lo->compositor->compositor, - NULL, name); + head, name); if (!output->output) { free(output); return NULL; @@ -2315,8 +2317,8 @@ drm_try_attach(struct weston_output *output, { unsigned i; - /* try to attach all heads, this probably succeeds */ - for (i = 0; i < add->n; i++) { + /* try to attach remaining heads, this probably succeeds */ + for (i = 1; i < add->n; i++) { if (!add->heads[i]) continue; @@ -2432,7 +2434,8 @@ drm_process_layoutput(struct wet_compositor *wet, struct wet_layoutput *lo) if (ret < 0) return -1; } - output = wet_layoutput_create_output(lo, name); + output = wet_layoutput_create_output_with_head(lo, name, + lo->add.heads[0]); free(name); name = NULL;