From af110dbce2ef15f4a23f9789d8b0a02eb2ca6b30 Mon Sep 17 00:00:00 2001 From: crs Date: Sat, 3 May 2003 13:28:21 +0000 Subject: [PATCH] Now turning off auto-repeat when on an X11 client. This prevents the server from auto-repeating fake events, which is undesired since synergy will do the auto-repeating itself. This also disables auto-repeat on any keys locally configured on X11 to not auto-repeat. That's mainly to suppress auto-repeat on modifier keys, which auto-repeat on win32 but not X11. --- lib/platform/CXWindowsSecondaryScreen.cpp | 34 +++++++++++++++++++++++ lib/platform/CXWindowsSecondaryScreen.h | 4 +++ 2 files changed, 38 insertions(+) diff --git a/lib/platform/CXWindowsSecondaryScreen.cpp b/lib/platform/CXWindowsSecondaryScreen.cpp index 0fbbc223..598cc4ed 100644 --- a/lib/platform/CXWindowsSecondaryScreen.cpp +++ b/lib/platform/CXWindowsSecondaryScreen.cpp @@ -139,6 +139,11 @@ CXWindowsSecondaryScreen::keyRepeat(KeyID key, return; } + // if this keycode shouldn't auto-repeat then ignore + if ((m_keyControl.auto_repeats[keycode >> 3] & (1 << (keycode & 7))) == 0) { + return; + } + // if we've seen this button (and we should have) then make sure // we release the same key we pressed when we saw it. if (index != m_serverKeyMap.end() && keycode != index->second) { @@ -367,6 +372,10 @@ void CXWindowsSecondaryScreen::onPostOpen() { assert(m_window != None); + + // get the keyboard control state + CDisplayLock display(m_screen); + XGetKeyboardControl(display, &m_keyControl); } void @@ -375,10 +384,35 @@ CXWindowsSecondaryScreen::onPreEnter() assert(m_window != None); } +void +CXWindowsSecondaryScreen::onPostEnter() +{ + assert(m_window != None); + + // get the keyboard control state + CDisplayLock display(m_screen); + XGetKeyboardControl(display, &m_keyControl); + + // turn off auto-repeat. we do this so fake key press events don't + // cause the local server to generate their own auto-repeats of + // those keys. + XAutoRepeatOff(display); +} + void CXWindowsSecondaryScreen::onPreLeave() { assert(m_window != None); + + // restore the previous keyboard auto-repeat state. if the user + // changed the auto-repeat configuration while on the client then + // that state is lost. that's because we can't get notified by + // the X server when the auto-repeat configuration is changed so + // we can't track the desired configuration. + if (m_keyControl.global_auto_repeat == AutoRepeatModeOn) { + CDisplayLock display(m_screen); + XAutoRepeatOn(display); + } } void diff --git a/lib/platform/CXWindowsSecondaryScreen.h b/lib/platform/CXWindowsSecondaryScreen.h index d8c6a88d..ae0655d7 100644 --- a/lib/platform/CXWindowsSecondaryScreen.h +++ b/lib/platform/CXWindowsSecondaryScreen.h @@ -62,6 +62,7 @@ protected: virtual void onPreOpen(); virtual void onPostOpen(); virtual void onPreEnter(); + virtual void onPostEnter(); virtual void onPreLeave(); virtual void createWindow(); virtual void destroyWindow(); @@ -170,6 +171,9 @@ private: // map server key buttons to local keycodes ServerKeyMap m_serverKeyMap; + + // the keyboard control state the last time this screen was entered + XKeyboardState m_keyControl; }; #endif