From b36b4ab8161eb59c0bb731a2aba20d6d7588b42b Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Tue, 10 Mar 2026 22:54:54 -0600 Subject: [PATCH] output: exit compositor when last nested output is destroyed When running on the X11 or Wayland backend, each output corresponds to a window in the parent compositor. Unlike DRM outputs, these cannot be reconnected after being destroyed. Terminate the compositor when the last output is destroyed on these nested backends, matching the expected behavior when the user closes the window. --- src/output.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/output.c b/src/output.c index f62dd87e..4533cab3 100644 --- a/src/output.c +++ b/src/output.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,17 @@ handle_output_destroy(struct wl_listener *listener, void *data) */ output->wlr_output->data = NULL; + /* + * On nested backends (X11/Wayland), outputs correspond to + * windows and cannot be reconnected. Exit the compositor + * when the last one is destroyed. + */ + if (wl_list_empty(&server->outputs) + && (wlr_output_is_x11(output->wlr_output) + || wlr_output_is_wl(output->wlr_output))) { + wl_display_terminate(server->wl_display); + } + /* * output->scene_output (if still around at this point) is * destroyed automatically when the wlr_output is destroyed