output: add brightness state

This commit is contained in:
Simon Ser 2026-05-29 16:55:37 +02:00
parent 15a378316e
commit 82d2cc7c23
3 changed files with 29 additions and 0 deletions

View file

@ -261,6 +261,10 @@ static void output_apply_state(struct wlr_output *output,
}
}
if (state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) {
output->brightness = state->brightness;
}
bool geometry_updated = state->committed &
(WLR_OUTPUT_STATE_MODE | WLR_OUTPUT_STATE_TRANSFORM |
WLR_OUTPUT_STATE_SUBPIXEL);
@ -359,6 +363,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
.render_format = DRM_FORMAT_XRGB8888,
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
.scale = 1,
.brightness = 1,
.commit_seq = 0,
};
@ -590,6 +595,10 @@ static uint32_t output_compare_state(struct wlr_output *output,
output->color_range == state->color_range) {
fields |= WLR_OUTPUT_STATE_COLOR_REPRESENTATION;
}
if ((state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) &&
output->brightness == state->brightness) {
fields |= WLR_OUTPUT_STATE_BRIGHTNESS;
}
return fields;
}
@ -687,6 +696,7 @@ static bool output_basic_test(struct wlr_output *output,
{ WLR_OUTPUT_STATE_SUBPIXEL, "subpixel" },
{ WLR_OUTPUT_STATE_COLOR_TRANSFORM, "color transform" },
{ WLR_OUTPUT_STATE_IMAGE_DESCRIPTION, "image description" },
{ WLR_OUTPUT_STATE_BRIGHTNESS, "brightness" },
};
if (!enabled) {
for (size_t i = 0; i < sizeof(needs_enabled) / sizeof(needs_enabled[0]); i++) {
@ -726,6 +736,12 @@ static bool output_basic_test(struct wlr_output *output,
}
}
if ((state->committed & WLR_OUTPUT_STATE_BRIGHTNESS) &&
!output->brightness_supported) {
wlr_log(WLR_DEBUG, "Brightness is not supported for this output");
return false;
}
return true;
}

View file

@ -149,6 +149,11 @@ void wlr_output_state_set_color_encoding_and_range(
state->color_range = range;
}
void wlr_output_state_set_brightness(struct wlr_output_state *state, float value) {
state->committed |= WLR_OUTPUT_STATE_BRIGHTNESS;
state->brightness = value;
}
bool wlr_output_state_copy(struct wlr_output_state *dst,
const struct wlr_output_state *src) {
struct wlr_output_state copy = *src;