config/output: Always set output states from config

queue_output_config had some remaining logic that would avoid setting
output states if they already appeared to be in effect. That is not what
most of the states did nor what is currently expected, so clean that up.
This commit is contained in:
Kenny Levinsen 2024-10-17 00:19:29 +02:00
parent 7d93652105
commit 7e0c0dda42

View file

@ -451,54 +451,41 @@ static void queue_output_config(struct output_config *oc,
wlr_output_state_set_mode(pending, preferred_mode); wlr_output_state_set_mode(pending, preferred_mode);
} }
if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) { if (oc && oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN) {
sway_log(SWAY_DEBUG, "Set %s subpixel to %s", oc->name,
sway_wl_output_subpixel_to_string(oc->subpixel));
wlr_output_state_set_subpixel(pending, oc->subpixel); wlr_output_state_set_subpixel(pending, oc->subpixel);
} else {
wlr_output_state_set_subpixel(pending, output->detected_subpixel);
} }
enum wl_output_transform tr = WL_OUTPUT_TRANSFORM_NORMAL;
if (oc && oc->transform >= 0) { if (oc && oc->transform >= 0) {
tr = oc->transform; wlr_output_state_set_transform(pending, oc->transform);
#if WLR_HAS_DRM_BACKEND #if WLR_HAS_DRM_BACKEND
} else if (wlr_output_is_drm(wlr_output)) { } else if (wlr_output_is_drm(wlr_output)) {
tr = wlr_drm_connector_get_panel_orientation(wlr_output); wlr_output_state_set_transform(pending,
sway_log(SWAY_DEBUG, "Auto-detected output transform: %d", tr); wlr_drm_connector_get_panel_orientation(wlr_output));
#endif #endif
} } else {
if (wlr_output->transform != tr) { wlr_output_state_set_transform(pending, WL_OUTPUT_TRANSFORM_NORMAL);
sway_log(SWAY_DEBUG, "Set %s transform to %d", wlr_output->name, tr);
wlr_output_state_set_transform(pending, tr);
} }
// Apply the scale last before the commit, because the scale auto-detection // Apply the scale after sorting out the mode, because the scale
// reads the pending output size // auto-detection reads the pending output size
float scale;
if (oc && oc->scale > 0) { if (oc && oc->scale > 0) {
scale = oc->scale;
// The factional-scale-v1 protocol uses increments of 120ths to send // The factional-scale-v1 protocol uses increments of 120ths to send
// the scale factor to the client. Adjust the scale so that we use the // the scale factor to the client. Adjust the scale so that we use the
// same value as the clients'. // same value as the clients'.
float adjusted_scale = round(scale * 120) / 120; wlr_output_state_set_scale(pending, round(oc->scale * 120) / 120);
if (scale != adjusted_scale) {
sway_log(SWAY_INFO, "Adjusting output scale from %f to %f",
scale, adjusted_scale);
scale = adjusted_scale;
}
} else { } else {
scale = compute_default_scale(wlr_output, pending); wlr_output_state_set_scale(pending,
sway_log(SWAY_DEBUG, "Auto-detected output scale: %f", scale); compute_default_scale(wlr_output, pending));
}
if (scale != wlr_output->scale) {
sway_log(SWAY_DEBUG, "Set %s scale to %f", wlr_output->name, scale);
wlr_output_state_set_scale(pending, scale);
} }
if (oc && oc->adaptive_sync != -1 && wlr_output->adaptive_sync_supported) { if (wlr_output->adaptive_sync_supported) {
sway_log(SWAY_DEBUG, "Set %s adaptive sync to %d", wlr_output->name, if (oc && oc->adaptive_sync != -1) {
oc->adaptive_sync); wlr_output_state_set_adaptive_sync_enabled(pending, oc->adaptive_sync == 1);
wlr_output_state_set_adaptive_sync_enabled(pending, oc->adaptive_sync == 1); } else {
wlr_output_state_set_adaptive_sync_enabled(pending, false);
}
} }
if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) { if (oc && oc->render_bit_depth != RENDER_BIT_DEPTH_DEFAULT) {
@ -513,6 +500,8 @@ static void queue_output_config(struct output_config *oc,
} else { } else {
wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB8888); wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB8888);
} }
} else {
wlr_output_state_set_render_format(pending, DRM_FORMAT_XRGB8888);
} }
} }