1
0
mirror of https://github.com/emersion/kanshi synced 2024-09-18 09:51:36 +02:00

Select highest refresh rate for selected mode when none is specified.

This commit is contained in:
James Walmsley 2020-01-12 18:37:40 +00:00 committed by Simon Ser
parent 3d6b62ff0d
commit 86d6aff25f

20
main.c
View File

@ -167,13 +167,25 @@ static bool match_refresh(const struct kanshi_mode *mode, int refresh) {
static struct kanshi_mode *match_mode(struct kanshi_head *head,
int width, int height, int refresh) {
struct kanshi_mode *mode;
struct kanshi_mode *last_match = NULL;
wl_list_for_each(mode, &head->modes, link) {
if (mode->width == width && mode->height == height &&
(refresh == 0 || match_refresh(mode, refresh))) {
return mode;
if (mode->width != width || mode->height != height) {
continue;
}
if (refresh) {
if (match_refresh(mode, refresh)) {
return mode;
}
} else {
if (!last_match || mode->refresh > last_match->refresh) {
last_match = mode;
}
}
}
return NULL;
return last_match;
}
static void apply_profile(struct kanshi_state *state,