Added logging and handling of "half-duplex" caps-lock key.

This commit is contained in:
crs 2002-04-30 16:25:29 +00:00
parent c2a69d6c64
commit 56877bcc7d
2 changed files with 26 additions and 1 deletions

View File

@ -156,6 +156,11 @@ void CXWindowsSecondaryScreen::open(CClient* client)
updateModifiers(display); 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 // assume primary has all clipboards
for (ClipboardID id = 0; id < kClipboardEnd; ++id) for (ClipboardID id = 0; id < kClipboardEnd; ++id)
grabClipboard(id); grabClipboard(id);
@ -403,18 +408,28 @@ KeyModifierMask CXWindowsSecondaryScreen::mapKey(
// keysym with that mask. we override the bits in the mask // keysym with that mask. we override the bits in the mask
// that cannot be accomodated. // 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 // lookup the a keycode for this key id. also return the
// key modifier mask required. // key modifier mask required.
unsigned int outMask; unsigned int outMask;
if (!findKeyCode(keycode, outMask, id, maskToX(mask))) { if (!findKeyCode(keycode, outMask, id, maskToX(mask))) {
// we cannot generate the desired keysym because no key // we cannot generate the desired keysym because no key
// maps to that keysym. just return the current mask. // maps to that keysym. just return the current mask.
log((CLOG_DEBUG2 "no keycode for keysym %d modifiers %04x", id, mask));
return m_mask; return m_mask;
} }
// if we cannot match the modifier mask then don't return any // if we cannot match the modifier mask then don't return any
// keys and just return the current mask. // keys and just return the current mask.
if ((outMask & m_modifierMask) != outMask) { if ((outMask & m_modifierMask) != outMask) {
log((CLOG_DEBUG2 "cannot match modifiers %04x", outMask));
return m_mask; 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 // add the key event
keys.push_back(std::make_pair(keycode, press)); 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 // toggle keys modify the state on press if toggling on and on
// release if toggling off. other keys set the bit on press // 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 ((modifierBit & m_toggleModifierMask) != 0) {
if (((mask & modifierBit) == 0) == press) if (((mask & modifierBit) == 0) == press)
mask ^= modifierBit; mask ^= modifierBit;

View File

@ -68,6 +68,10 @@ private:
CClient* m_client; CClient* m_client;
Window m_window; 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. // set entries indicate keys that are pressed. indexed by keycode.
bool m_keys[256]; bool m_keys[256];