From ad787c3cf7a9874e0a0dbd48cfc0de39cc997334 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 16 Jul 2021 12:00:03 -0700 Subject: [PATCH] input-mapper: Reverse sort order of display score comparator The `guess_candidates()` function scores each display that an input device could be mapped to and then uses the `sort_by_score()` comparator to find the best option. The function expects the list to be sorted from best to worst, but the comparator currently sorts them in the opposite order. This causes the function to end up returning the _worst_ match rather than the the best. This commit reverses the sort order of the comparator so that the best display can be returned as intended. Closes: #1889 (Cherry-picked from commit 64ff1f20f81749b3b00ace5a8b73487747a8ed3d) --- src/backends/meta-input-mapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/meta-input-mapper.c b/src/backends/meta-input-mapper.c index ffbe2dd37..c0a32a382 100644 --- a/src/backends/meta-input-mapper.c +++ b/src/backends/meta-input-mapper.c @@ -473,7 +473,7 @@ static int sort_by_score (DeviceMatch *match1, DeviceMatch *match2) { - return (int) match1->score - match2->score; + return (int) match2->score - match1->score; } static void