diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 84837a59d..eefddb024 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -429,6 +429,13 @@ void wlr_output_lock_software_cursors(struct wlr_output *output, bool lock); */ void wlr_output_render_software_cursors(struct wlr_output *output, pixman_region32_t *damage); +/** + * Queue pending output state from `state`. + * + * Users need to call `wlr_output_commit` to apply the pending state. + */ +void wlr_output_queue_state(struct wlr_output *output, + const struct wlr_output_state *state); struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output); diff --git a/types/wlr_output.c b/types/wlr_output.c index 9790691a0..bfa1379eb 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -728,6 +728,48 @@ void wlr_output_send_present(struct wlr_output *output, wlr_signal_emit_safe(&output->events.present, event); } +void wlr_output_queue_state(struct wlr_output *output, + const struct wlr_output_state *state) { + assert(state != &output->pending); + + if (state->committed & WLR_OUTPUT_STATE_BUFFER) { + assert(state->buffer_type == WLR_OUTPUT_STATE_BUFFER_SCANOUT); + wlr_output_attach_buffer(output, state->buffer); + } + if (state->committed & WLR_OUTPUT_STATE_DAMAGE) { + wlr_output_set_damage(output, (pixman_region32_t *)&state->damage); + } + if (state->committed & WLR_OUTPUT_STATE_MODE) { + switch (state->mode_type) { + case WLR_OUTPUT_STATE_MODE_FIXED: + wlr_output_set_mode(output, state->mode); + break; + case WLR_OUTPUT_STATE_MODE_CUSTOM: + wlr_output_set_custom_mode(output, state->custom_mode.width, + state->custom_mode.height, state->custom_mode.refresh); + break; + } + } + if (state->committed & WLR_OUTPUT_STATE_ENABLED) { + wlr_output_enable(output, state->enabled); + } + if (state->committed & WLR_OUTPUT_STATE_SCALE) { + wlr_output_set_scale(output, state->scale); + } + if (state->committed & WLR_OUTPUT_STATE_TRANSFORM) { + wlr_output_set_transform(output, state->transform); + } + if (state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) { + wlr_output_enable_adaptive_sync(output, state->adaptive_sync_enabled); + } + if (state->committed & WLR_OUTPUT_STATE_GAMMA_LUT) { + const uint16_t *r = state->gamma_lut; + const uint16_t *g = state->gamma_lut + state->gamma_lut_size; + const uint16_t *b = state->gamma_lut + 2 * state->gamma_lut_size; + wlr_output_set_gamma(output, state->gamma_lut_size, r, g, b); + } +} + void wlr_output_set_gamma(struct wlr_output *output, size_t size, const uint16_t *r, const uint16_t *g, const uint16_t *b) { output_state_clear_gamma_lut(&output->pending);