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
This commit is contained in:
Simon Ser 2022-10-20 09:49:16 +02:00
parent 2ee59e1a08
commit f0ee563416

View file

@ -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, void wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
int32_t height, int32_t refresh) { 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); wlr_output_state_set_custom_mode(&output->pending, width, height, refresh);
} }