From 56877bcc7dcb1feb134b158d573f15eb535759b6 Mon Sep 17 00:00:00 2001 From: crs Date: Tue, 30 Apr 2002 16:25:29 +0000 Subject: [PATCH] Added logging and handling of "half-duplex" caps-lock key. --- client/CXWindowsSecondaryScreen.cpp | 23 ++++++++++++++++++++++- client/CXWindowsSecondaryScreen.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/client/CXWindowsSecondaryScreen.cpp b/client/CXWindowsSecondaryScreen.cpp index cc935285..d1ea46ab 100644 --- a/client/CXWindowsSecondaryScreen.cpp +++ b/client/CXWindowsSecondaryScreen.cpp @@ -156,6 +156,11 @@ void CXWindowsSecondaryScreen::open(CClient* client) updateModifiers(display); } + // check for peculiarities + // FIXME -- may have to get these from some database + m_capsLockHalfDuplex = false; +// m_capsLockHalfDuplex = true; + // assume primary has all clipboards for (ClipboardID id = 0; id < kClipboardEnd; ++id) grabClipboard(id); @@ -403,18 +408,28 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey( // keysym with that mask. we override the bits in the mask // that cannot be accomodated. + // note if the key is the caps lock and it's "half-duplex" + const bool isHalfDuplex = (id == XK_Caps_Lock && m_capsLockHalfDuplex); + + // ignore releases for half-duplex keys + if (isHalfDuplex && !press) { + return m_mask; + } + // lookup the a keycode for this key id. also return the // key modifier mask required. unsigned int outMask; if (!findKeyCode(keycode, outMask, id, maskToX(mask))) { // we cannot generate the desired keysym because no key // maps to that keysym. just return the current mask. + log((CLOG_DEBUG2 "no keycode for keysym %d modifiers %04x", id, mask)); return m_mask; } // if we cannot match the modifier mask then don't return any // keys and just return the current mask. if ((outMask & m_modifierMask) != outMask) { + log((CLOG_DEBUG2 "cannot match modifiers %04x", outMask)); return m_mask; } @@ -482,6 +497,11 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey( } } + // note if the press of a half-duplex key should be treated as a release + if (isHalfDuplex && (m_mask & (1 << index->second)) != 0) { + press = false; + } + // add the key event keys.push_back(std::make_pair(keycode, press)); @@ -501,7 +521,8 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey( // toggle keys modify the state on press if toggling on and on // release if toggling off. other keys set the bit on press - // and clear the bit on release. + // and clear the bit on release. if half-duplex then toggle + // each time we get here. if ((modifierBit & m_toggleModifierMask) != 0) { if (((mask & modifierBit) == 0) == press) mask ^= modifierBit; diff --git a/client/CXWindowsSecondaryScreen.h b/client/CXWindowsSecondaryScreen.h index 4e0f8c2e..66fe2c55 100644 --- a/client/CXWindowsSecondaryScreen.h +++ b/client/CXWindowsSecondaryScreen.h @@ -68,6 +68,10 @@ private: CClient* m_client; Window m_window; + // note if caps lock key toggles on up/down (false) or on + // transition (true) + bool m_capsLockHalfDuplex; + // set entries indicate keys that are pressed. indexed by keycode. bool m_keys[256];