Fixed caps-lock and num-lock behavior. It seems to work okay

now but did notice one problem:  when powerbook is primary and
num-lock is on the keypad works fine until shift is pressed
(and released);  after that the keypad only works while the
shift key is down.
This commit is contained in:
crs 2002-04-26 20:14:46 +00:00
parent 242109d430
commit 79b4d333fa
1 changed files with 9 additions and 51 deletions

View File

@ -522,61 +522,19 @@ bool CXWindowsSecondaryScreen::findKeyCode(
// generate the id keysym and match maskIn. it's possible that // generate the id keysym and match maskIn. it's possible that
// maskIn wants, say, a shift key to be down but that would make // maskIn wants, say, a shift key to be down but that would make
// it impossible to generate the keysym. in that case we must // it impossible to generate the keysym. in that case we must
// override maskIn. // override maskIn. this is complicated by caps/shift-lock and
// // num-lock.
// this is complicated by caps/shift-lock and num-lock. for
// example, if id is a keypad keysym and maskIn indicates that
// shift is not active but keyMask indicates that shift is
// required then we can either activate shift and then send
// the keycode or we can activate num-lock and then send the
// keycode. the latter is better because applications may
// treat, say, shift+Home differently than Home.
maskOut = (maskIn & ~index->second.keyMaskMask); maskOut = (maskIn & ~index->second.keyMaskMask);
if (IsKeypadKey(id) || IsPrivateKeypadKey(id)) { if (IsKeypadKey(id) || IsPrivateKeypadKey(id)) {
// compare shift state of maskIn and keyMask maskOut |= index->second.keyMask;
const bool agree = ((maskIn & ShiftMask) ==
(index->second.keyMask & ShiftMask));
// get num-lock state
const bool numLockActive = ((m_mask & m_numLockMask) != 0);
// if num-lock is active and the shift states agree or if
// num-lock is not active and the shift states do not agree
// then we should toggle num-lock.
if (numLockActive == agree) {
maskOut |= (maskIn & ShiftMask) |
(index->second.keyMask & ~ShiftMask);
if (numLockActive)
maskOut &= ~m_numLockMask; maskOut &= ~m_numLockMask;
else
maskOut |= m_numLockMask;
} }
else { else {
maskOut |= index->second.keyMask; unsigned int maskShift = (index->second.keyMask & ShiftMask);
} if (index->second.keyMaskMask != 0 && (m_mask & m_capsLockMask) != 0)
} maskShift ^= ShiftMask;
else { maskOut |= maskShift | (m_mask & m_capsLockMask);
// compare shift state of maskIn and keyMask maskOut |= (index->second.keyMask & ~(ShiftMask | LockMask));
const bool agree = ((maskIn & ShiftMask) ==
(index->second.keyMask & ShiftMask));
// get caps-lock state
const bool capsLockActive = ((m_mask & m_capsLockMask) != 0);
// if caps-lock is active and the shift states agree or if
// caps-lock is not active and the shift states do not agree
// then we should toggle caps-lock.
if (capsLockActive == agree) {
maskOut |= (maskIn & ShiftMask) |
(index->second.keyMask & ~ShiftMask);
if (capsLockActive)
maskOut &= ~m_capsLockMask;
else
maskOut |= m_capsLockMask;
}
else {
maskOut |= index->second.keyMask;
}
} }
return true; return true;