From a9d7069f9c6185796a44c9790f6badd0b59124f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand=20=28astrand=29?= Date: Mon, 7 May 2018 09:58:59 +0200 Subject: [PATCH] Comparing ScreenSet:s should be done without considering order 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/rfb/ScreenSet.h b/common/rfb/ScreenSet.h index ad340c2b..9680b6e7 100644 --- a/common/rfb/ScreenSet.h +++ b/common/rfb/ScreenSet.h @@ -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 a = screens; + a.sort(compare_screen); + std::list b = r.screens; + b.sort(compare_screen); + return a == b; + }; + inline bool operator!=(const ScreenSet& r) const { return !operator==(r); } std::list screens; + + private: + static inline bool compare_screen(const Screen& first, const Screen& second) + { + return first.id < second.id; + } + }; }; -- 2.39.5