diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xwin/winkeybd.c')
-rw-r--r-- | xc/programs/Xserver/hw/xwin/winkeybd.c | 126 |
1 files changed, 106 insertions, 20 deletions
diff --git a/xc/programs/Xserver/hw/xwin/winkeybd.c b/xc/programs/Xserver/hw/xwin/winkeybd.c index 5df741748..05b5bf5d6 100644 --- a/xc/programs/Xserver/hw/xwin/winkeybd.c +++ b/xc/programs/Xserver/hw/xwin/winkeybd.c @@ -30,7 +30,7 @@ * Peter Busch * Harold L Hunt II */ -/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.c,v 1.1 2001/04/18 17:14:06 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.c,v 1.2 2001/05/02 00:45:26 alanh Exp $ */ #include "win.h" @@ -66,9 +66,9 @@ winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode) } /* - Handle extended keys that weren't handled correctly as - non-extended keys. - */ + * Handle extended keys that weren't handled correctly as + * non-extended keys. + */ if (HIWORD (lParam) & KF_EXTENDED) { switch (wParam) @@ -235,7 +235,12 @@ void winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt, pointer pCtrl, int iClass) { - + /* + * Window 95 and later ignore the parameters to Beep. + * Systems with sound cards will play the default sound event; + * systems without sound cards will play the standard system beep. + */ + Beep (0, 0); } /* Change some keyboard configuration parameters */ @@ -356,9 +361,9 @@ winInitializeModeKeyStates (void) } /* - We have to store the last state of each mode - key before we lose the keyboard focus. -*/ + * We have to store the last state of each mode + * key before we lose the keyboard focus. + */ void winStoreModeKeyStates (ScreenPtr pScreen) { @@ -381,10 +386,10 @@ winStoreModeKeyStates (ScreenPtr pScreen) } /* - Upon regaining the keyboard focus we must - resynchronize our internal mode key states - with the actual state of the keys. -*/ + * Upon regaining the keyboard focus we must + * resynchronize our internal mode key states + * with the actual state of the keys. + */ void winRestoreModeKeyStates (ScreenPtr pScreen) { @@ -393,8 +398,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen) ZeroMemory (&xCurrentEvent, sizeof (xCurrentEvent)); /* Has the key state changed? */ - if (WIN_XOR(pScreenPriv->dwModeKeyStates & NumLockMask, - GetKeyState (VK_NUMLOCK) & 0x0001)) + if ((pScreenPriv->dwModeKeyStates & NumLockMask) + ^ (GetKeyState (VK_NUMLOCK) & 0x0001)) { xCurrentEvent.u.u.detail = KEY_NumLock + MIN_KEYCODE; @@ -410,8 +415,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen) } /* Has the key state changed? */ - if (WIN_XOR(pScreenPriv->dwModeKeyStates & LockMask, - GetKeyState (VK_CAPITAL) & 0x0001)) + if ((pScreenPriv->dwModeKeyStates & LockMask) + ^ (GetKeyState (VK_CAPITAL) & 0x0001)) { xCurrentEvent.u.u.detail = KEY_CapsLock + MIN_KEYCODE; @@ -427,8 +432,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen) } /* Has the key state changed? */ - if (WIN_XOR(pScreenPriv->dwModeKeyStates & ScrollLockMask, - GetKeyState (VK_SCROLL) & 0x0001)) + if ((pScreenPriv->dwModeKeyStates & ScrollLockMask) + ^ (GetKeyState (VK_SCROLL) & 0x0001)) { xCurrentEvent.u.u.detail = KEY_ScrollLock + MIN_KEYCODE; @@ -444,8 +449,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen) } /* Has the key state changed? */ - if (WIN_XOR(pScreenPriv->dwModeKeyStates & KanaMask, - GetKeyState (VK_KANA) & 0x0001)) + if ((pScreenPriv->dwModeKeyStates & KanaMask) + ^ (GetKeyState (VK_KANA) & 0x0001)) { xCurrentEvent.u.u.detail = KEY_HKTG + MIN_KEYCODE; @@ -461,5 +466,86 @@ winRestoreModeKeyStates (ScreenPtr pScreen) } } +/* + * Look for the lovely fake Control_L press/release generated by Windows + * when AltGr is pressed/released on a non-U.S. keyboard. + */ +Bool +winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam) +{ + MSG msgNext; + LONG lTime; + Bool fReturn; + + /* + * Fake Ctrl_L presses will be followed by an Alt_R keypress + * with the same timestamp as the Ctrl_L press. + */ + if (message == WM_KEYDOWN + && wParam == VK_CONTROL + && (HIWORD (lParam) & KF_EXTENDED) == 0) + { + /* Got a Ctrl_L press */ + + /* Get time of current message */ + lTime = GetMessageTime (); + + /* Look for fake Ctrl_L preceeding an Alt_R press. */ + fReturn = PeekMessage (&msgNext, NULL, + WM_KEYDOWN, WM_KEYDOWN, + PM_NOREMOVE); + + /* Is next press an Alt_R with the same timestamp? */ + if (fReturn && msgNext.wParam == VK_MENU + && msgNext.time == lTime + && (HIWORD (msgNext.lParam) & KF_EXTENDED)) + { + /* + * Next key press is Alt_R with same timestamp as current + * Ctrl_L message. Therefore, this Ctrl_L press is a fake + * event, so discard it. + */ + return TRUE; + } + } + + /* + * Fake Ctrl_L releases will be followed by an Alt_R release + * with the same timestamp as the Ctrl_L press. + */ + if ((message == WM_KEYUP || message == WM_SYSKEYUP) + && wParam == VK_CONTROL + && (HIWORD (lParam) & KF_EXTENDED) == 0) + { + /* Got a Ctrl_L release */ + + /* Get time of current message */ + lTime = GetMessageTime (); + + /* Look for fake Ctrl_L release preceeding an Alt_R release. */ + fReturn = PeekMessage (&msgNext, NULL, + WM_KEYUP, WM_SYSKEYUP, + PM_NOREMOVE); + + /* Is next press an Alt_R with the same timestamp? */ + if (fReturn + && (msgNext.message == WM_KEYUP + || msgNext.message == WM_SYSKEYUP) + && msgNext.wParam == VK_MENU + && msgNext.time == lTime + && (HIWORD (msgNext.lParam) & KF_EXTENDED)) + { + /* + * Next key release is Alt_R with same timestamp as current + * Ctrl_L message. Therefore, this Ctrl_L release is a fake + * event, so discard it. + */ + return TRUE; + } + } + + /* Not a fake control left press/release */ + return FALSE; +} |