output: shorten output enabled checks

Use a more concise loop instead of repeated logic.

No behavior change.
This commit is contained in:
Simon Ser 2025-06-20 19:02:54 +02:00
parent 0c272a3842
commit 98af337175

View file

@ -627,33 +627,25 @@ static bool output_basic_test(struct wlr_output *output,
} }
} }
if (!enabled && state->committed & WLR_OUTPUT_STATE_BUFFER) { const struct {
wlr_log(WLR_DEBUG, "Tried to commit a buffer on a disabled output"); enum wlr_output_state_field field;
return false; const char *name;
} } needs_enabled[] = {
if (!enabled && state->committed & WLR_OUTPUT_STATE_MODE) { { WLR_OUTPUT_STATE_BUFFER, "buffer" },
wlr_log(WLR_DEBUG, "Tried to modeset a disabled output"); { WLR_OUTPUT_STATE_MODE, "mode" },
return false; { WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED, "adaptive sync" },
} { WLR_OUTPUT_STATE_RENDER_FORMAT, "render format" },
if (!enabled && state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) { { WLR_OUTPUT_STATE_SUBPIXEL, "subpixel" },
wlr_log(WLR_DEBUG, "Tried to enable adaptive sync on a disabled output"); { WLR_OUTPUT_STATE_COLOR_TRANSFORM, "color transform" },
return false; { WLR_OUTPUT_STATE_IMAGE_DESCRIPTION, "image description" },
} };
if (!enabled && state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) { if (!enabled) {
wlr_log(WLR_DEBUG, "Tried to set format for a disabled output"); for (size_t i = 0; i < sizeof(needs_enabled) / sizeof(needs_enabled[0]); i++) {
return false; if (state->committed & needs_enabled[i].field) {
} wlr_log(WLR_DEBUG, "Tried to set %s on a disabled output", needs_enabled[i].name);
if (!enabled && state->committed & WLR_OUTPUT_STATE_SUBPIXEL) { return false;
wlr_log(WLR_DEBUG, "Tried to set the subpixel layout on a disabled output"); }
return false; }
}
if (!enabled && state->committed & WLR_OUTPUT_STATE_COLOR_TRANSFORM) {
wlr_log(WLR_DEBUG, "Tried to set a color transform on a disabled output");
return false;
}
if (!enabled && state->committed & WLR_OUTPUT_STATE_IMAGE_DESCRIPTION) {
wlr_log(WLR_DEBUG, "Tried to set the image description on a disabled output");
return false;
} }
if (state->committed & WLR_OUTPUT_STATE_LAYERS) { if (state->committed & WLR_OUTPUT_STATE_LAYERS) {