diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 88568ff96..d23077f6b 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -651,26 +651,6 @@ void Client::handleClipboardGrabbed(const Event &event, void *) } } -bool Client::isCompatible(int major, int minor) const -{ - const std::map> compatibleTable{ - {6, {7, 8}}, // 1.6 is compatible with 1.7 and 1.8 - {7, {8}} // 1.7 is compatible with 1.8 - }; - - bool isCompatible = false; - - if (major == kProtocolMajorVersion) { - auto versions = compatibleTable.find(minor); - if (versions != compatibleTable.end()) { - auto compatibleVersions = versions->second; - isCompatible = compatibleVersions.find(kProtocolMinorVersion) != compatibleVersions.end(); - } - } - - return isCompatible; -} - void Client::handleHello(const Event &, void *) { SInt16 major, minor; @@ -682,16 +662,18 @@ void Client::handleHello(const Event &, void *) } // check versions - LOG((CLOG_DEBUG1 "got hello version %d.%d", major, minor)); + LOG((CLOG_DEBUG "got hello version %d.%d", major, minor)); SInt16 helloBackMajor = kProtocolMajorVersion; SInt16 helloBackMinor = kProtocolMinorVersion; - if (isCompatible(major, minor)) { - // because 1.6 is comptable with 1.7 and 1.8 - downgrading protocol for - // server - LOG((CLOG_NOTE "downgrading protocol version for server")); + // only allow client minor version to downgrade, as major versions will likely not be compatible. + if (major == kProtocolMajorVersion && minor < kProtocolMinorVersion) { helloBackMinor = minor; - } else if (major < kProtocolMajorVersion || (major == kProtocolMajorVersion && minor < kProtocolMinorVersion)) { + LOG_NOTE( + "downgrading client protocol version from %d.%d to %d.%d", // + kProtocolMajorVersion, kProtocolMinorVersion, helloBackMajor, helloBackMinor + ); + } else if (major != kProtocolMajorVersion) { sendConnectionFailedEvent(XIncompatibleClient(major, minor).what()); cleanupTimer(); cleanupConnection(); @@ -699,7 +681,7 @@ void Client::handleHello(const Event &, void *) } // say hello back - LOG((CLOG_DEBUG1 "say hello version %d.%d", helloBackMajor, helloBackMinor)); + LOG((CLOG_DEBUG "say hello version %d.%d", helloBackMajor, helloBackMinor)); ProtocolUtil::writef(m_stream, kMsgHelloBack, helloBackMajor, helloBackMinor, &m_name); // now connected but waiting to complete handshake diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index 7460b0bb1..e0f341ad5 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -217,7 +217,6 @@ class Client : public IClient, public INode void handleDisconnected(const Event &, void *); void handleShapeChanged(const Event &, void *); void handleClipboardGrabbed(const Event &, void *); - bool isCompatible(int major, int minor) const; void handleHello(const Event &, void *); void handleSuspend(const Event &event, void *); void handleResume(const Event &event, void *);