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.
This commit is contained in:
Jonathan Marler 2026-03-10 22:54:54 -06:00 committed by Consolatis
parent f0589810ad
commit b36b4ab816

View file

@ -12,6 +12,7 @@
#include <strings.h>
#include <wlr/backend/drm.h>
#include <wlr/backend/wayland.h>
#include <wlr/backend/x11.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
@ -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