When primary output gets disconnected and there
were views created, they won't get assigned a
new output when a new primary output gets plugged
in. This will lead to crashes when weston tries
to use an already destroyed output.

This fixes the problems by force-moving all views
to the newly attached output if there were no
outputs present.

Signed-off-by: Armin Krezović <[email protected]>
---
 libweston/compositor.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index eb9e8d9..62687cf 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4313,8 +4313,18 @@ WL_EXPORT void
 weston_compositor_add_output(struct weston_compositor *compositor,
                              struct weston_output *output)
 {
+       struct weston_view *view;
+       int reassign_outputs = 0;
+
+       if (wl_list_empty(&compositor->output_list))
+               reassign_outputs = 1;
+
        wl_list_insert(compositor->output_list.prev, &output->link);
        wl_signal_emit(&compositor->output_created_signal, output);
+
+       if (reassign_outputs)
+               wl_list_for_each(view, &compositor->view_list, link)
+                       weston_view_assign_output(view);
 }
 
 WL_EXPORT void
-- 
2.9.0

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to