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