From 2c3053370c274f86411dda1c5fced6b1416d8ad1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 7 Nov 2024 11:40:19 +0100 Subject: [PATCH] output-management-v1: only create custom mode object for enabled heads We were always creating a custom mode object when the output didn't have a fixed mode. This is important to handle two cases: - Virtual outputs with no concept of fixed modes. - DRM outputs with a list of fixed modes but with a custom mode set. However, in the case where an output didn't have a fixed mode and was disabled, we were also creating the custom mode object. Clients would then see a "ghost" mode: a mode object with no properties at all. Fix this by only creating the custom mode object if the output is enabled. Fixes: 5de9e1a99d66 ("wlr-output-management: Send custom modes to clients") Closes: https://github.com/swaywm/sway/issues/8420 --- types/wlr_output_management_v1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/wlr_output_management_v1.c b/types/wlr_output_management_v1.c index 551453e6b..32f6b4ffe 100644 --- a/types/wlr_output_management_v1.c +++ b/types/wlr_output_management_v1.c @@ -866,7 +866,7 @@ static void manager_send_head(struct wlr_output_manager_v1 *manager, head_send_mode(head, head_resource, mode); } - if (output->current_mode == NULL) { + if (head->state.mode == NULL && head->state.enabled) { // Output doesn't have a fixed mode set. Send a virtual one. head_send_mode(head, head_resource, NULL); } @@ -926,7 +926,7 @@ static bool manager_update_head(struct wlr_output_manager_v1 *manager, } } - if (next->mode == NULL && !head_has_custom_mode_resources(head)) { + if (next->mode == NULL && next->enabled && !head_has_custom_mode_resources(head)) { struct wl_resource *resource; wl_resource_for_each(resource, &head->resources) { head_send_mode(head, resource, NULL);