aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2021-07-30 23:00:10 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2021-08-12 21:06:26 +0200
commit4cdc4ac63aeb7f5e17c42ad3317978bd31e1fde2 (patch)
treea7efd4bc886dbb33df30387255a92192f62fe9b3
parentlayer_shell: damage previous area when a surface shrinks (diff)
downloadsway-4cdc4ac63aeb7f5e17c42ad3317978bd31e1fde2.tar.gz
sway-4cdc4ac63aeb7f5e17c42ad3317978bd31e1fde2.tar.zst
sway-4cdc4ac63aeb7f5e17c42ad3317978bd31e1fde2.zip
Fallback to other output modes if preferred mode fails
Sometimes the preferred mode is not available due to hardware constraints (e.g. GPU or cable bandwidth limitations). In these cases it's better to fallback to lower modes than to end up with a black screen.
-rw-r--r--sway/config/output.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 7d0ed395..6224fc10 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -357,8 +357,26 @@ static void queue_output_config(struct output_config *oc,
357 set_mode(wlr_output, oc->width, oc->height, 357 set_mode(wlr_output, oc->width, oc->height,
358 oc->refresh_rate, oc->custom_mode == 1); 358 oc->refresh_rate, oc->custom_mode == 1);
359 } else if (!wl_list_empty(&wlr_output->modes)) { 359 } else if (!wl_list_empty(&wlr_output->modes)) {
360 struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); 360 sway_log(SWAY_DEBUG, "Set preferred mode");
361 wlr_output_set_mode(wlr_output, mode); 361 struct wlr_output_mode *preferred_mode =
362 wlr_output_preferred_mode(wlr_output);
363 wlr_output_set_mode(wlr_output, preferred_mode);
364
365 if (!wlr_output_test(wlr_output)) {
366 sway_log(SWAY_DEBUG, "Preferred mode rejected, "
367 "falling back to another mode");
368 struct wlr_output_mode *mode;
369 wl_list_for_each(mode, &wlr_output->modes, link) {
370 if (mode == preferred_mode) {
371 continue;
372 }
373
374 wlr_output_set_mode(wlr_output, mode);
375 if (wlr_output_test(wlr_output)) {
376 break;
377 }
378 }
379 }
362 } 380 }
363 381
364 if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) { 382 if (oc && (oc->subpixel != WL_OUTPUT_SUBPIXEL_UNKNOWN || config->reloading)) {