From 162451962f03e9a897ed489db4d1e54badf1dceb Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 28 Mar 2024 13:55:06 +0200 Subject: compositor: Fix loading nested X11/Wayland backends The AGL compositor frontend uses ivi_output to denote an output and pass it around, with the implication that's available on retrieval later on. In order for that to actually work, and by the mechanism we are retriving it we need to install a destruction handler a bit earlier, such that is available. Bug-AGL: SPEC-5096, SPEC-5061 Signed-off-by: Marius Vlad Change-Id: Ifbbfff67c75f98fe4ce84613674fb308880bf7e6 --- src/compositor.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index cd36eeb..abc7daa 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -182,6 +182,9 @@ to_ivi_output(struct weston_output *o) struct ivi_output *output; listener = weston_output_get_destroy_listener(o, handle_output_destroy); + if (!listener) + return NULL; + output = wl_container_of(listener, output, output_destroy); return output; @@ -238,6 +241,14 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, return NULL; } + /* simple_output_configure might assume we have an ivi_output created + * by this point, which we do but we can only link it to a + * weston_output through the destroy listener, so install it earlier + * before actually running the callback handler */ + output->output_destroy.notify = handle_output_destroy; + weston_output_add_destroy_listener(output->output, + &output->output_destroy); + if (ivi->simple_output_configure) { int ret = ivi->simple_output_configure(output->output); if (ret < 0) { @@ -257,12 +268,10 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name, } } - output->output_destroy.notify = handle_output_destroy; - weston_output_add_destroy_listener(output->output, - &output->output_destroy); wl_list_insert(&ivi->outputs, &output->link); ivi_output_configure_app_id(output); + return output; } @@ -334,6 +343,9 @@ ivi_configure_windowed_output_from_config(struct ivi_output *output, height = defaults->height; } free(mode); + } else { + width = defaults->width; + height = defaults->height; } scale = defaults->scale; @@ -342,7 +354,6 @@ ivi_configure_windowed_output_from_config(struct ivi_output *output, width = ivi->cmdline.width; if (ivi->cmdline.height) height = ivi->cmdline.height; - if (ivi->cmdline.scale) scale = ivi->cmdline.scale; @@ -1177,6 +1188,8 @@ windowed_create_outputs(struct ivi_compositor *ivi, int output_count, static int wayland_backend_output_configure(struct weston_output *output) { + struct ivi_output *ivi_output = to_ivi_output(output); + struct ivi_output_config defaults = { .width = WINDOWED_DEFAULT_WIDTH, .height = WINDOWED_DEFAULT_HEIGHT, @@ -1184,6 +1197,11 @@ wayland_backend_output_configure(struct weston_output *output) .transform = WL_OUTPUT_TRANSFORM_NORMAL }; + if (!ivi_output) { + weston_log("Failed to configure and enable Wayland output. No ivi-output available!\n"); + return -1; + } + return ivi_configure_windowed_output_from_config(to_ivi_output(output), &defaults); } @@ -1256,6 +1274,8 @@ load_wayland_backend(struct ivi_compositor *ivi, int *argc, char *argv[], static int x11_backend_output_configure(struct weston_output *output) { + struct ivi_output *ivi_output = to_ivi_output(output); + struct ivi_output_config defaults = { .width = WINDOWED_DEFAULT_WIDTH, .height = WINDOWED_DEFAULT_HEIGHT, @@ -1263,7 +1283,13 @@ x11_backend_output_configure(struct weston_output *output) .transform = WL_OUTPUT_TRANSFORM_NORMAL }; - return ivi_configure_windowed_output_from_config(to_ivi_output(output), &defaults); + if (!ivi_output) { + weston_log("Failed to configure and enable X11 output. No ivi-output available!\n"); + return -1; + } + + + return ivi_configure_windowed_output_from_config(ivi_output, &defaults); } static int -- cgit 1.2.3-korg