@@ -651,26 +651,6 @@ void Client::handleClipboardGrabbed(const Event &event, void *)
651651 }
652652}
653653
654- bool Client::isCompatible (int major, int minor) const
655- {
656- const std::map<int , std::set<int >> compatibleTable{
657- {6 , {7 , 8 }}, // 1.6 is compatible with 1.7 and 1.8
658- {7 , {8 }} // 1.7 is compatible with 1.8
659- };
660-
661- bool isCompatible = false ;
662-
663- if (major == kProtocolMajorVersion ) {
664- auto versions = compatibleTable.find (minor);
665- if (versions != compatibleTable.end ()) {
666- auto compatibleVersions = versions->second ;
667- isCompatible = compatibleVersions.find (kProtocolMinorVersion ) != compatibleVersions.end ();
668- }
669- }
670-
671- return isCompatible;
672- }
673-
674654void Client::handleHello (const Event &, void *)
675655{
676656 SInt16 major, minor;
@@ -682,24 +662,26 @@ void Client::handleHello(const Event &, void *)
682662 }
683663
684664 // check versions
685- LOG ((CLOG_DEBUG1 " got hello version %d.%d" , major, minor));
665+ LOG ((CLOG_DEBUG " got hello version %d.%d" , major, minor));
686666 SInt16 helloBackMajor = kProtocolMajorVersion ;
687667 SInt16 helloBackMinor = kProtocolMinorVersion ;
688668
689- if (isCompatible (major, minor)) {
690- // because 1.6 is comptable with 1.7 and 1.8 - downgrading protocol for
691- // server
692- LOG ((CLOG_NOTE " downgrading protocol version for server" ));
669+ // only allow client minor version to downgrade, as major versions will likely not be compatible.
670+ if (major == kProtocolMajorVersion && minor < kProtocolMinorVersion ) {
693671 helloBackMinor = minor;
694- } else if (major < kProtocolMajorVersion || (major == kProtocolMajorVersion && minor < kProtocolMinorVersion )) {
672+ LOG_NOTE (
673+ " downgrading client protocol version from %d.%d to %d.%d" , //
674+ kProtocolMajorVersion , kProtocolMinorVersion , helloBackMajor, helloBackMinor
675+ );
676+ } else if (major != kProtocolMajorVersion ) {
695677 sendConnectionFailedEvent (XIncompatibleClient (major, minor).what ());
696678 cleanupTimer ();
697679 cleanupConnection ();
698680 return ;
699681 }
700682
701683 // say hello back
702- LOG ((CLOG_DEBUG1 " say hello version %d.%d" , helloBackMajor, helloBackMinor));
684+ LOG ((CLOG_DEBUG " say hello version %d.%d" , helloBackMajor, helloBackMinor));
703685 ProtocolUtil::writef (m_stream, kMsgHelloBack , helloBackMajor, helloBackMinor, &m_name);
704686
705687 // now connected but waiting to complete handshake
0 commit comments