output: use state setters in wlr_output_set_*

This commit is contained in:
Simon Ser 2022-06-07 19:32:20 +02:00
parent 43a9b0fbb9
commit c2e4ba1dd0

View file

@ -205,52 +205,17 @@ static void output_update_matrix(struct wlr_output *output) {
} }
void wlr_output_enable(struct wlr_output *output, bool enable) { void wlr_output_enable(struct wlr_output *output, bool enable) {
if (output->enabled == enable) { wlr_output_state_set_enabled(&output->pending, enable);
output->pending.committed &= ~WLR_OUTPUT_STATE_ENABLED;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_ENABLED;
output->pending.enabled = enable;
}
static void output_state_clear_mode(struct wlr_output_state *state) {
if (!(state->committed & WLR_OUTPUT_STATE_MODE)) {
return;
}
state->mode = NULL;
state->committed &= ~WLR_OUTPUT_STATE_MODE;
} }
void wlr_output_set_mode(struct wlr_output *output, void wlr_output_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode) { struct wlr_output_mode *mode) {
output_state_clear_mode(&output->pending); wlr_output_state_set_mode(&output->pending, mode);
if (output->current_mode == mode) {
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_MODE;
output->pending.mode_type = WLR_OUTPUT_STATE_MODE_FIXED;
output->pending.mode = mode;
} }
void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width, void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh) { int32_t height, int32_t refresh) {
output_state_clear_mode(&output->pending); wlr_output_state_set_custom_mode(&output->pending, width, height, refresh);
if (output->width == width && output->height == height &&
output->refresh == refresh) {
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_MODE;
output->pending.mode_type = WLR_OUTPUT_STATE_MODE_CUSTOM;
output->pending.custom_mode.width = width;
output->pending.custom_mode.height = height;
output->pending.custom_mode.refresh = refresh;
} }
void wlr_output_update_mode(struct wlr_output *output, void wlr_output_update_mode(struct wlr_output *output,
@ -295,56 +260,24 @@ void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width,
void wlr_output_set_transform(struct wlr_output *output, void wlr_output_set_transform(struct wlr_output *output,
enum wl_output_transform transform) { enum wl_output_transform transform) {
if (output->transform == transform) { wlr_output_state_set_transform(&output->pending, transform);
output->pending.committed &= ~WLR_OUTPUT_STATE_TRANSFORM;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_TRANSFORM;
output->pending.transform = transform;
} }
void wlr_output_set_scale(struct wlr_output *output, float scale) { void wlr_output_set_scale(struct wlr_output *output, float scale) {
if (output->scale == scale) { wlr_output_state_set_scale(&output->pending, scale);
output->pending.committed &= ~WLR_OUTPUT_STATE_SCALE;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_SCALE;
output->pending.scale = scale;
} }
void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled) { void wlr_output_enable_adaptive_sync(struct wlr_output *output, bool enabled) {
bool currently_enabled = wlr_output_state_set_adaptive_sync_enabled(&output->pending, enabled);
output->adaptive_sync_status != WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED;
if (currently_enabled == enabled) {
output->pending.committed &= ~WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
output->pending.adaptive_sync_enabled = enabled;
} }
void wlr_output_set_render_format(struct wlr_output *output, uint32_t format) { void wlr_output_set_render_format(struct wlr_output *output, uint32_t format) {
if (output->render_format == format) { wlr_output_state_set_render_format(&output->pending, format);
output->pending.committed &= ~WLR_OUTPUT_STATE_RENDER_FORMAT;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_RENDER_FORMAT;
output->pending.render_format = format;
} }
void wlr_output_set_subpixel(struct wlr_output *output, void wlr_output_set_subpixel(struct wlr_output *output,
enum wl_output_subpixel subpixel) { enum wl_output_subpixel subpixel) {
if (output->subpixel == subpixel) { wlr_output_state_set_subpixel(&output->pending, subpixel);
output->pending.committed &= ~WLR_OUTPUT_STATE_SUBPIXEL;
return;
}
output->pending.committed |= WLR_OUTPUT_STATE_SUBPIXEL;
output->pending.subpixel = subpixel;
} }
void wlr_output_set_name(struct wlr_output *output, const char *name) { void wlr_output_set_name(struct wlr_output *output, const char *name) {