From: Pierre Ossman Date: Thu, 9 Sep 2021 09:04:21 +0000 (+0200) Subject: Fix corner case in monitor index calculation X-Git-Tag: v1.12.90~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=72d632673ba4531132fd1cd59c2d0b9966551300;p=tigervnc.git 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. --- 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; }