From 72d632673ba4531132fd1cd59c2d0b9966551300 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 9 Sep 2021 11:04:21 +0200 Subject: [PATCH] Fix corner case in monitor index calculation Fix a bug in the comparison function that could result in the wrong index being assigned to a monitor. Change the logic to more directly map to the description. --- vncviewer/MonitorIndicesParameter.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vncviewer/MonitorIndicesParameter.cxx b/vncviewer/MonitorIndicesParameter.cxx index ad791504..5130831c 100644 --- a/vncviewer/MonitorIndicesParameter.cxx +++ b/vncviewer/MonitorIndicesParameter.cxx @@ -243,12 +243,14 @@ int MonitorIndicesParameter::compare(const void *a, const void *b) if (monitor1->x < monitor2->x) return -1; + if (monitor1->x > monitor2->x) + return 1; + if (monitor1->y < monitor2->y) return -1; - if (monitor1->x == monitor2->x) - if (monitor1->y == monitor2->y) - return 0; + if (monitor1->y > monitor2->y) + return 1; - return 1; + return 0; } -- 2.39.5