checkpoint. now sending toggle modifier state when entering

a screen.  this allows the secondary screen to set it's
modifier state to match the primary screen's state.  this is
not strictly necessary since each keystroke should adjust the
modifier state as needed to get the right result.
This commit is contained in:
crs
2002-04-30 17:48:11 +00:00
parent 56877bcc7d
commit b279c80608
17 changed files with 224 additions and 32 deletions

View File

@@ -109,11 +109,12 @@ void CMSWindowsSecondaryScreen::close()
m_client = NULL;
}
void CMSWindowsSecondaryScreen::enter(SInt32 x, SInt32 y)
void CMSWindowsSecondaryScreen::enter(
SInt32 x, SInt32 y, KeyModifierMask mask)
{
assert(m_window != NULL);
log((CLOG_INFO "entering screen at %d,%d", x, y));
log((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
// warp to requested location
SInt32 w, h;
@@ -130,6 +131,17 @@ void CMSWindowsSecondaryScreen::enter(SInt32 x, SInt32 y)
// update our keyboard state to reflect the local state
updateKeys();
updateModifiers();
// toggle modifiers that don't match the desired state
if ((mask & KeyModifierCapsLock) != (m_mask & KeyModifierCapsLock)) {
toggleKey(VK_CAPITAL, KeyModifierCapsLock);
}
if ((mask & KeyModifierNumLock) != (m_mask & KeyModifierNumLock)) {
toggleKey(VK_NUMLOCK, KeyModifierNumLock);
}
if ((mask & KeyModifierScrollLock) != (m_mask & KeyModifierScrollLock)) {
toggleKey(VK_SCROLL, KeyModifierScrollLock);
}
}
void CMSWindowsSecondaryScreen::leave()
@@ -1184,3 +1196,16 @@ void CMSWindowsSecondaryScreen::updateModifiers()
if ((m_keys[VK_SCROLL] & 0x01) != 0)
m_mask |= KeyModifierScrollLock;
}
void CMSWindowsSecondaryScreen::toggleKey(
UINT virtualKey, KeyModifierMask mask)
{
// send key events to simulate a press and release
const UINT code = MapVirtualKey(virtualKey, 0);
keybd_event(virtualKey, code, 0, 0);
keybd_event(virtualKey, code, KEYEVENTF_KEYUP, 0);
// toggle shadow state
m_mask ^= mask;
m_keys[virtualKey] ^= 0x01;
}