Use wlr_output_preferred_mode instead of the last mode

Instead of relying on the order of modes, use wlr_output_preferred_mode
to get the preferred mode.
This commit is contained in:
Simon Ser 2019-11-05 08:11:13 +01:00 committed by Brian Ashworth
parent 01b5350bdc
commit f576bcdb8c

View file

@ -229,8 +229,8 @@ static bool set_mode(struct wlr_output *output, int width, int height,
} }
if (!best) { if (!best) {
sway_log(SWAY_ERROR, "Configured mode for %s not available", output->name); sway_log(SWAY_ERROR, "Configured mode for %s not available", output->name);
sway_log(SWAY_INFO, "Picking default mode instead"); sway_log(SWAY_INFO, "Picking preferred mode instead");
best = wl_container_of(output->modes.prev, mode, link); best = wlr_output_preferred_mode(output);
} else { } else {
sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name); sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name);
} }
@ -272,8 +272,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
modeset_success = set_mode(wlr_output, oc->width, oc->height, modeset_success = set_mode(wlr_output, oc->width, oc->height,
oc->refresh_rate, oc->custom_mode == 1); oc->refresh_rate, oc->custom_mode == 1);
} else if (!wl_list_empty(&wlr_output->modes)) { } else if (!wl_list_empty(&wlr_output->modes)) {
struct wlr_output_mode *mode = struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
wl_container_of(wlr_output->modes.prev, mode, link);
modeset_success = wlr_output_set_mode(wlr_output, mode); modeset_success = wlr_output_set_mode(wlr_output, mode);
} else { } else {
// Output doesn't support modes // Output doesn't support modes
@ -332,9 +331,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
static void default_output_config(struct output_config *oc, static void default_output_config(struct output_config *oc,
struct wlr_output *wlr_output) { struct wlr_output *wlr_output) {
oc->enabled = 1; oc->enabled = 1;
if (!wl_list_empty(&wlr_output->modes)) { struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
struct wlr_output_mode *mode = if (mode != NULL) {
wl_container_of(wlr_output->modes.prev, mode, link);
oc->width = mode->width; oc->width = mode->width;
oc->height = mode->height; oc->height = mode->height;
oc->refresh_rate = mode->refresh / 1000.f; oc->refresh_rate = mode->refresh / 1000.f;