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: 5de9e1a99d ("wlr-output-management: Send custom modes to clients")
Closes: https://github.com/swaywm/sway/issues/8420
This commit is contained in:
Simon Ser 2024-11-07 11:40:19 +01:00 committed by Simon Zeni
parent e9a6b3b85d
commit 2c3053370c

View File

@ -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);