compositor-wayland: fix mode_list corruption on --sprawl

The wayland-backend with --sprawl is one way to trigger
wayland_output_create_for_parent_output(), which intends to find a mode
from the parent mode list and use it. Calling wayland_output_set_size()
initialized an embedded struct weston_mode and inserts that into the
mode list. Then the assignment output->mode = *mode; corrupts the
mode_list by overwriting the link entry. This leads to an endless loop
in bind_output() in compositor.c.

Fix this by manually doing the setup that wayland_output_set_size() did
and do not call it.

As a side effect, it now relays the parent compositor's physical output
size to our own clients. It no longer smashes the refresh rate either.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Pekka Paalanen 2017-10-19 13:19:50 +03:00
parent afee695adc
commit 4dab58343b

View File

@ -1376,18 +1376,22 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
output->base.scale = 1;
output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
if (wayland_output_set_size(&output->base, mode->width, mode->height) < 0)
goto out;
output->mode = *mode;
output->parent.output = poutput->global;
output->base.make = poutput->physical.make;
output->base.model = poutput->physical.model;
output->base.mm_width = poutput->physical.width;
output->base.mm_height = poutput->physical.height;
wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
wl_list_init(&poutput->mode_list);
/* No other mode should have CURRENT already. */
mode->flags |= WL_OUTPUT_MODE_CURRENT;
output->base.current_mode = mode;
/* output->mode is unused in this path. */
weston_compositor_add_pending_output(&output->base, b->compositor);
return 0;