From f0ee563416cb926c302aa5c98ef85aaab44b1646 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 20 Oct 2022 09:49:16 +0200 Subject: [PATCH] output: try to use fixed mode in wlr_output_set_custom_mode() If a fixed mode matching the user requirements is available, use that. This avoids generating the mode with GTF or CVT in the DRM backend, and instead uses mode timings advertised by the output. References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3514 --- types/output/output.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/output/output.c b/types/output/output.c index 04361231..9a2e5515 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -215,6 +215,16 @@ void wlr_output_set_mode(struct wlr_output *output, void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width, int32_t height, int32_t refresh) { + // If there is a fixed mode which matches what the user wants, use that + struct wlr_output_mode *mode; + wl_list_for_each(mode, &output->modes, link) { + if (mode->width == width && mode->height == height && + mode->refresh == refresh) { + wlr_output_set_mode(output, mode); + return; + } + } + wlr_output_state_set_custom_mode(&output->pending, width, height, refresh); }