[PATCH spice-gtk] main: use stable comparison function for monitors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If monitors are equal, compare them by their addresses, to get the
effect of a stable sort.
---
 gtk/channel-main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index fe57684..f86e81d 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -973,8 +973,9 @@ static int monitors_cmp(const void *p1, const void *p2, gpointer user_data)
     const VDAgentMonConfig *m2 = p2;
     double d1 = sqrt(m1->x * m1->x + m1->y * m1->y);
     double d2 = sqrt(m2->x * m2->x + m2->y * m2->y);
+    int diff = d1 - d2;
 
-    return d1 - d2;
+    return diff == 0 ? (char*)p1 - (char*)p2 : diff;
 }
 
 static void monitors_align(VDAgentMonConfig *monitors, int nmonitors)
-- 
1.8.1.1.439.g50a6b54

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]