Hi,

On 02/20/2013 11:35 AM, Marc-André Lureau wrote:
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;

I think that should be: "(char*)p2 - (char*)p1" So that if the
address of p2 is bigger they compare as p2 > p1, and qsort will
keep the order of the array the same for monitors with identical
coordinates.

Regards,

Hans
_______________________________________________
Spice-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to