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:
parent
242109d430
commit
79b4d333fa
|
@ -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) ==
|
maskOut &= ~m_numLockMask;
|
||||||
(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;
|
|
||||||
else
|
|
||||||
maskOut |= m_numLockMask;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
maskOut |= index->second.keyMask;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// compare shift state of maskIn and keyMask
|
unsigned int maskShift = (index->second.keyMask & ShiftMask);
|
||||||
const bool agree = ((maskIn & ShiftMask) ==
|
if (index->second.keyMaskMask != 0 && (m_mask & m_capsLockMask) != 0)
|
||||||
(index->second.keyMask & ShiftMask));
|
maskShift ^= ShiftMask;
|
||||||
|
maskOut |= maskShift | (m_mask & m_capsLockMask);
|
||||||
// get caps-lock state
|
maskOut |= (index->second.keyMask & ~(ShiftMask | LockMask));
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue