compositor-wayland: avoid recursive dispatch with wl_outputs
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 19 Oct 2017 09:03:06 +0000 (12:03 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Mon, 23 Oct 2017 07:29:42 +0000 (10:29 +0300)
commitb07de934ccc8783a48b1055d0207dc06701eeb31
treed1d1176625c06a8ecdb6e6ffb28638e2cc432708
parentaedcd8ebb08de9ea9d4d6ebdb37b3b6f8368b83b
compositor-wayland: avoid recursive dispatch with wl_outputs

Calling wl_display_roundtrip() from within a Wayland event handler means
we will re-enter event dispatch, that is, it will lead to recursive
dispatch. Even if libwayland-client was safe, this would lead to
unexpected code paths: the first event handler function has not returned
when other event handler functions may get called. In this particular
case it maybe didn't hurt, but it's still a fragile pattern to use.

Replace the wl_display_roundtrip() with a manual sync callback to do the
work.

This does not break the wayland-backend initialization sequence, because
sprawl_across_outputs was set only after the roundtrip to ensure
wl_registry globals have been received so the code would not have been
hit anyway, and weston_backend_init() also has a second roundtrip that
ensures the per wl_output events have been received before continuing.

For wayland-backend output hotplug the change is insignificant because
it will only delay the output creation a bit, and the parent outputs are
not processed anywhere in between.

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>
libweston/compositor-wayland.c