]> source.dussan.org Git - tigervnc.git/commitdiff
Comparing ScreenSet:s should be done without considering order
authorPeter Åstrand (astrand) <astrand@cendio.se>
Mon, 7 May 2018 07:58:59 +0000 (09:58 +0200)
committerPeter Åstrand (astrand) <astrand@cendio.se>
Mon, 7 May 2018 07:58:59 +0000 (09:58 +0200)
Avoids that a viewer connected to Xvnc sometimes disconnects with
"Desktop configured a different screen layout than requested" when
screens are changing.

common/rfb/ScreenSet.h

index ad340c2b6249ba597ac79d6dd410a397abc80882..9680b6e78e906c7a66378c0484f6f91363c84020 100644 (file)
@@ -126,11 +126,23 @@ namespace rfb {
       }
     };
 
-    // FIXME: List order shouldn't matter
-    inline bool operator==(const ScreenSet& r) const { return screens == r.screens; }
-    inline bool operator!=(const ScreenSet& r) const { return screens != r.screens; }
+    inline bool operator==(const ScreenSet& r) const {
+      std::list<Screen> a = screens;
+      a.sort(compare_screen);
+      std::list<Screen> b = r.screens;
+      b.sort(compare_screen);
+      return a == b;
+    };
+    inline bool operator!=(const ScreenSet& r) const { return !operator==(r); }
 
     std::list<Screen> screens;
+
+  private:
+    static inline bool compare_screen(const Screen& first, const Screen& second)
+    {
+      return first.id < second.id;
+    }
+
   };
 
 };