From 9a1de9f10524ff7235af88a0b930d517335347d9 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 23 Oct 2004 19:43:37 +0000 Subject: [PATCH] Previous half-duplex fix fixed secondary screens with half duplex keys but broke primary screens. This fixes both and also ensures that the primary screen updates its shadow toggle modifier state when leaving so the secondary screens get the correct toggle modifier state. Together these fix some strange inconsistencies in toggle state across screens. --- lib/synergy/CKeyState.cpp | 19 +++++++++++++++---- lib/synergy/CKeyState.h | 2 +- lib/synergy/CScreen.cpp | 5 ++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/synergy/CKeyState.cpp b/lib/synergy/CKeyState.cpp index c5c75007..41a859d9 100644 --- a/lib/synergy/CKeyState.cpp +++ b/lib/synergy/CKeyState.cpp @@ -39,7 +39,7 @@ void CKeyState::setKeyDown(KeyButton button, bool down) { button &= kButtonMask; - updateKeyState(button, button, down); + updateKeyState(button, button, down, false); } void @@ -149,7 +149,7 @@ CKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button) fakeKeyEvents(keys, 1); // note that key is down - updateKeyState((KeyButton)(button & kButtonMask), localID, true); + updateKeyState((KeyButton)(button & kButtonMask), localID, true, true); } void @@ -230,7 +230,7 @@ CKeyState::fakeKeyUp(KeyButton button) fakeKeyEvents(keys, 1); // note that key is now up - updateKeyState(button, localID, false); + updateKeyState(button, localID, false, true); } void @@ -486,7 +486,8 @@ CKeyState::fakeKeyEvent(KeyButton button, bool press, bool isAutoRepeat) } void -CKeyState::updateKeyState(KeyButton serverID, KeyButton localID, bool press) +CKeyState::updateKeyState(KeyButton serverID, KeyButton localID, + bool press, bool fake) { // ignore bogus keys if (serverID == 0 || localID == 0) { @@ -510,6 +511,16 @@ CKeyState::updateKeyState(KeyButton serverID, KeyButton localID, bool press) // never report half-duplex keys as down if (isHalfDuplex(mask)) { m_keys[localID] &= ~kDown; + // half-duplex keys on the primary screen don't send the + // usual press/release pairs but instead send the press + // when toggling on and the release when toggleing off. + // since we normally toggle our shadow state on the press + // we need to treat the release as a press on the primary + // screen. we know we're on the primary screen if fake is + // false. secondary screens always get press/release pairs. + if (!fake) { + press = true; + } } // toggle on the press diff --git a/lib/synergy/CKeyState.h b/lib/synergy/CKeyState.h index 00c28eb4..a003b78a 100644 --- a/lib/synergy/CKeyState.h +++ b/lib/synergy/CKeyState.h @@ -152,7 +152,7 @@ private: void fakeKeyEvents(const Keystrokes&, UInt32 count); void fakeKeyEvent(KeyButton, bool press, bool isAutoRepeat); void updateKeyState(KeyButton serverID, - KeyButton localID, bool press); + KeyButton localID, bool press, bool fake); private: enum { diff --git a/lib/synergy/CScreen.cpp b/lib/synergy/CScreen.cpp index 0323d8a8..c7543645 100644 --- a/lib/synergy/CScreen.cpp +++ b/lib/synergy/CScreen.cpp @@ -469,7 +469,10 @@ CScreen::enterSecondary(KeyModifierMask toggleMask) void CScreen::leavePrimary() { - // do nothing + // we don't track keys while on the primary screen so update our + // idea of them now. this is particularly to update the state of + // the toggle modifiers. + m_screen->updateKeys(); } void