From 708d1dbe60a77c19c5a02a7adbebb2f93ec348b5 Mon Sep 17 00:00:00 2001 From: hustlerone Date: Fri, 20 Feb 2026 21:07:56 +0100 Subject: [PATCH 1/3] subprojects/wf-config: bump dependency It's required to be able to make use of `MODE_HIGHRR` and `MODE_HIGHRES` as alternatives to `AUTO`. --- subprojects/wf-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/wf-config b/subprojects/wf-config index d89d630ff..a2051f5d1 160000 --- a/subprojects/wf-config +++ b/subprojects/wf-config @@ -1 +1 @@ -Subproject commit d89d630ff3e3d8deb7813d6cd57b88e81ec059f9 +Subproject commit a2051f5d131a23acdcd96bfeb509d01cf57139ec From 1a20976bdac90c792b508a7ce47452127c13f61c Mon Sep 17 00:00:00 2001 From: hustlerone Date: Thu, 12 Feb 2026 16:00:17 +0100 Subject: [PATCH 2/3] output-layout: Add different automatic modes Adds in `MODE_HIGHRES` and `MODE_HIGHRR`. The former prioritises the biggest resolution no matter what. The former will prioritise highest refresh rate. `AUTO` behavior is unchanged. --- src/core/output-layout.cpp | 62 ++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/src/core/output-layout.cpp b/src/core/output-layout.cpp index f25b1e9db..841df7992 100644 --- a/src/core/output-layout.cpp +++ b/src/core/output-layout.cpp @@ -22,6 +22,7 @@ #include static void*const WF_NOOP_OUTPUT_MAGIC = (void*)0x1234; +static wlr_output_mode __video_mode_all_zeroes{}; // wlroots wrappers namespace wf @@ -450,22 +451,60 @@ struct output_layout_output_t } } - wlr_output_mode select_default_mode() + wlr_output_mode select_default_mode(wf::output_config::mode_type_t default_heuristic) { wlr_output_mode *mode; - wl_list_for_each(mode, &handle->modes, link) + + if (default_heuristic == output_config::MODE_HIGHRR) + { + int32_t max_refresh = 0; + wlr_output_mode *biggest_mode = &__video_mode_all_zeroes; + + // Get the highest refresh rate out of all modes. + + wl_list_for_each(mode, &handle->modes, link) + { + if (mode->refresh > max_refresh) + { + max_refresh = mode->refresh; + } + } + + /* Get the highest resolution compatible with the highest refresh rate. + * We measure it by calculating the area of each video mode. */ + + wl_list_for_each(mode, &handle->modes, link) + { + if (mode->refresh == max_refresh && ((mode->width * mode->height) > (biggest_mode->width * biggest_mode->height))) + { + biggest_mode = mode; + } + } + + // Don't return the dummy video mode. + if (biggest_mode != &__video_mode_all_zeroes) + { + return *biggest_mode; + } + } + else if (default_heuristic == output_config::MODE_AUTO) { - if (mode->preferred) + wl_list_for_each(mode, &handle->modes, link) { - return *mode; + if (mode->preferred) + { + return *mode; + } } } + /* Couldn't find a preferred mode. Just return the last, which is * usually also the "largest" */ wl_list_for_each_reverse(mode, &handle->modes, link) - - return *mode; + { + return *mode; + } /* Finally, if there isn't any mode (for ex. wayland backend), * try the wlr_output resolution, falling back to 1200x720 @@ -552,10 +591,13 @@ struct output_layout_output_t wf::output_config::mode_t mode = mode_opt; wlr_output_mode tmp{}; - switch (mode.get_type()) + wf::output_config::mode_type_t mode_type = mode.get_type(); + switch (mode_type) { + case output_config::MODE_HIGHRES: + case output_config::MODE_HIGHRR: case output_config::MODE_AUTO: - state.mode = select_default_mode(); + state.mode = select_default_mode(mode_type); state.source = OUTPUT_IMAGE_SOURCE_SELF; break; @@ -564,7 +606,7 @@ struct output_layout_output_t tmp.width = mode.get_width(); tmp.height = mode.get_height(); tmp.refresh = mode.get_refresh(); - state.mode = (is_mode_supported(tmp) ? tmp : select_default_mode()); + state.mode = (is_mode_supported(tmp) ? tmp : select_default_mode(output_config::MODE_AUTO)); state.source = OUTPUT_IMAGE_SOURCE_SELF; break; @@ -574,7 +616,7 @@ struct output_layout_output_t case output_config::MODE_MIRROR: state.source = OUTPUT_IMAGE_SOURCE_MIRROR; - state.mode = select_default_mode(); + state.mode = select_default_mode(output_config::MODE_AUTO); state.mirror_from = mode.get_mirror_from(); break; } From 6b24c811a300d20d05031a7482fec3f8dc64fb44 Mon Sep 17 00:00:00 2001 From: hustlerone Date: Thu, 12 Feb 2026 22:36:30 +0100 Subject: [PATCH 3/3] output-layout: explicitly calculate MODE_HIGHRES Just in case... --- src/core/output-layout.cpp | 65 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/core/output-layout.cpp b/src/core/output-layout.cpp index 841df7992..a7743b109 100644 --- a/src/core/output-layout.cpp +++ b/src/core/output-layout.cpp @@ -22,7 +22,6 @@ #include static void*const WF_NOOP_OUTPUT_MAGIC = (void*)0x1234; -static wlr_output_mode __video_mode_all_zeroes{}; // wlroots wrappers namespace wf @@ -454,30 +453,57 @@ struct output_layout_output_t wlr_output_mode select_default_mode(wf::output_config::mode_type_t default_heuristic) { wlr_output_mode *mode; + static wlr_output_mode __video_mode_all_zeroes{}; - if (default_heuristic == output_config::MODE_HIGHRR) + if (default_heuristic == output_config::MODE_AUTO) { - int32_t max_refresh = 0; - wlr_output_mode *biggest_mode = &__video_mode_all_zeroes; - - // Get the highest refresh rate out of all modes. - wl_list_for_each(mode, &handle->modes, link) { - if (mode->refresh > max_refresh) + if (mode->preferred) { - max_refresh = mode->refresh; + return *mode; } } + } else + { + wlr_output_mode *biggest_mode = &__video_mode_all_zeroes; - /* Get the highest resolution compatible with the highest refresh rate. - * We measure it by calculating the area of each video mode. */ + if (default_heuristic == output_config::MODE_HIGHRES) + { + /* Get the highest resolution compatible with the highest refresh rate. + * We measure it by calculating the area of each video mode. */ - wl_list_for_each(mode, &handle->modes, link) + wl_list_for_each(mode, &handle->modes, link) + { + if ((mode->width * mode->height) > (biggest_mode->width * biggest_mode->height)) + { + biggest_mode = mode; + } + } + } else if (default_heuristic == output_config::MODE_HIGHRR) { - if (mode->refresh == max_refresh && ((mode->width * mode->height) > (biggest_mode->width * biggest_mode->height))) + int32_t max_refresh = 0; + + // Get the highest refresh rate out of all modes. + + wl_list_for_each(mode, &handle->modes, link) { - biggest_mode = mode; + if (mode->refresh > max_refresh) + { + max_refresh = mode->refresh; + } + } + + /* Get the highest resolution compatible with the highest refresh rate. + * We measure it by calculating the area of each video mode. */ + + wl_list_for_each(mode, &handle->modes, link) + { + if ((mode->refresh == max_refresh) && + ((mode->width * mode->height) > (biggest_mode->width * biggest_mode->height))) + { + biggest_mode = mode; + } } } @@ -487,18 +513,7 @@ struct output_layout_output_t return *biggest_mode; } } - else if (default_heuristic == output_config::MODE_AUTO) - { - wl_list_for_each(mode, &handle->modes, link) - { - if (mode->preferred) - { - return *mode; - } - } - } - /* Couldn't find a preferred mode. Just return the last, which is * usually also the "largest" */ wl_list_for_each_reverse(mode, &handle->modes, link)