From 3730c591ccbe8f11bd918e1373750eb3ec8d2521 Mon Sep 17 00:00:00 2001 From: Jonathan GUILLOT Date: Mon, 28 Aug 2023 17:40:54 +0200 Subject: [PATCH] output: do not always terminate when last output is destroyed Only terminate if the last output was nested under the Wayland or X11 backend. If not, using DRM backend for example, terminating Cage when unplugging the last monitor or simply turning it off does not seem to be the right behavior. --- output.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/output.c b/output.c index 465c0ed..2d931ea 100644 --- a/output.c +++ b/output.c @@ -206,10 +206,25 @@ handle_output_layout_change(struct wl_listener *listener, void *data) update_output_manager_config(server); } +static bool +is_nested_output(struct cg_output *output) +{ + if (wlr_output_is_wl(output->wlr_output)) { + return true; + } +#if WLR_HAS_X11_BACKEND + if (wlr_output_is_x11(output->wlr_output)) { + return true; + } +#endif + return false; +} + static void output_destroy(struct cg_output *output) { struct cg_server *server = output->server; + bool was_nested_output = is_nested_output(output); output->wlr_output->data = NULL; @@ -223,7 +238,7 @@ output_destroy(struct cg_output *output) free(output); - if (wl_list_empty(&server->outputs)) { + if (wl_list_empty(&server->outputs) && was_nested_output) { wl_display_terminate(server->wl_display); } else if (server->output_mode == CAGE_MULTI_OUTPUT_MODE_LAST && !wl_list_empty(&server->outputs)) { struct cg_output *prev = wl_container_of(server->outputs.next, prev, link);