diff options
Diffstat (limited to 'xorg-server/hw/xwin/winkeybd.c')
-rw-r--r-- | xorg-server/hw/xwin/winkeybd.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c index 2ffb9a943..5da959cae 100644 --- a/xorg-server/hw/xwin/winkeybd.c +++ b/xorg-server/hw/xwin/winkeybd.c @@ -150,7 +150,7 @@ winKeybdProc(DeviceIntPtr pDeviceInt, int iState) /* FIXME: Maybe we should use winGetKbdLeds () here? */ defaultKeyboardControl.leds = g_winInfo.keyboard.leds; - winErrorFVerb(2, "Rules = \"%s\" Model = \"%s\" Layout = \"%s\"" + winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\"" " Variant = \"%s\" Options = \"%s\"\n", g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none", g_winInfo.xkb.model ? g_winInfo.xkb.model : "none", @@ -168,8 +168,7 @@ winKeybdProc(DeviceIntPtr pDeviceInt, int iState) ctrl->repeat_interval = 1000 / g_winInfo.keyboard.rate; } else { - winErrorFVerb(1, - "winKeybdProc - Error initializing keyboard AutoRepeat\n"); + winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n"); } break; @@ -259,12 +258,50 @@ winRestoreModeKeyStates(void) XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state); winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates); + { + /* Make sure the message queue is empty, otherwise the GetKeyState will not always + return the correct state of the numlock key, capslock key, ... + This is mainly because this function is called from the WM_SETFOCUS handler. + From MSDN GetKeyState: The key status returned from this function changes as a thread + reads key messages from its message queue.*/ + MSG msg; + + /* Process all messages on our queue */ + while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) + { + DispatchMessage (&msg); + } + } + /* * NOTE: The C XOR operator, ^, will not work here because it is * a bitwise operator, not a logical operator. C does not * have a logical XOR operator, so we use a macro instead. */ + { + /* consider modifer keys */ + + BOOL ctrl = (GetAsyncKeyState (VK_CONTROL) < 0); + BOOL shift = (GetAsyncKeyState (VK_SHIFT) < 0); + BOOL alt = (GetAsyncKeyState (VK_LMENU) < 0); + BOOL altgr = (GetAsyncKeyState (VK_RMENU) < 0); + + if (ctrl && altgr) ctrl = FALSE; + + if (WIN_XOR (internalKeyStates & ControlMask, ctrl)) + winSendKeyEvent (KEY_LCtrl, ctrl); + + if (WIN_XOR (internalKeyStates & ShiftMask, shift)) + winSendKeyEvent (KEY_ShiftL, shift); + + if (WIN_XOR (internalKeyStates & Mod1Mask, alt)) + winSendKeyEvent (KEY_Alt, alt); + + if (WIN_XOR (internalKeyStates & Mod5Mask, altgr)) + winSendKeyEvent (KEY_AltLang, altgr); + } + /* Has the key state changed? */ dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001; if (WIN_XOR(internalKeyStates & NumLockMask, dwKeyState)) { |