aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winkeybd.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-11-29 09:05:13 +0100
committermarha <marha@users.sourceforge.net>2012-11-29 09:05:49 +0100
commit0831039c0d449a3b5874c12ee365a8d5d2be7b8c (patch)
tree4edb707b79145f619fefc18c2359659ca660612f /xorg-server/hw/xwin/winkeybd.c
parent6bc629065956c81d836bbdb12f5f580d8a3db8e5 (diff)
parentd2d73da59e64acdc4718e4e6790a69d967bee875 (diff)
downloadvcxsrv-0831039c0d449a3b5874c12ee365a8d5d2be7b8c.tar.gz
vcxsrv-0831039c0d449a3b5874c12ee365a8d5d2be7b8c.tar.bz2
vcxsrv-0831039c0d449a3b5874c12ee365a8d5d2be7b8c.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig xserver mesa git update 29 nov 2012 Conflicts: xorg-server/dix/dispatch.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/winglobals.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwindow.h xorg-server/os/osinit.c xorg-server/os/utils.c
Diffstat (limited to 'xorg-server/hw/xwin/winkeybd.c')
-rwxr-xr-x[-rw-r--r--]xorg-server/hw/xwin/winkeybd.c84
1 files changed, 41 insertions, 43 deletions
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 5da959cae..8e035956d 100644..100755
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -41,6 +41,9 @@
#include "xkbsrv.h"
+/* C does not have a logical XOR operator, so we use a macro instead */
+#define LOGICAL_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
+
static Bool g_winKeyState[NUM_KEYCODES];
/*
@@ -258,74 +261,69 @@ 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);
+ /* 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);
+ /* Check if modifier keys are pressed, and if so, fake a press */
+ {
+ 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 (ctrl && altgr)
+ ctrl = FALSE;
- if (WIN_XOR (internalKeyStates & ControlMask, ctrl))
- winSendKeyEvent (KEY_LCtrl, ctrl);
+ if (LOGICAL_XOR(internalKeyStates & ControlMask, ctrl))
+ winSendKeyEvent(KEY_LCtrl, ctrl);
- if (WIN_XOR (internalKeyStates & ShiftMask, shift))
- winSendKeyEvent (KEY_ShiftL, shift);
+ if (LOGICAL_XOR(internalKeyStates & ShiftMask, shift))
+ winSendKeyEvent(KEY_ShiftL, shift);
- if (WIN_XOR (internalKeyStates & Mod1Mask, alt))
- winSendKeyEvent (KEY_Alt, alt);
+ if (LOGICAL_XOR(internalKeyStates & Mod1Mask, alt))
+ winSendKeyEvent(KEY_Alt, alt);
- if (WIN_XOR (internalKeyStates & Mod5Mask, altgr))
- winSendKeyEvent (KEY_AltLang, altgr);
- }
+ if (LOGICAL_XOR(internalKeyStates & Mod5Mask, altgr))
+ winSendKeyEvent(KEY_AltLang, altgr);
+ }
- /* Has the key state changed? */
+ /*
+ Check if latching modifier key states have changed, and if so,
+ fake a press and a release to toggle the modifier to the correct
+ state
+ */
dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001;
- if (WIN_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
+ if (LOGICAL_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
winSendKeyEvent(KEY_NumLock, TRUE);
winSendKeyEvent(KEY_NumLock, FALSE);
}
- /* Has the key state changed? */
dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
- if (WIN_XOR(internalKeyStates & LockMask, dwKeyState)) {
+ if (LOGICAL_XOR(internalKeyStates & LockMask, dwKeyState)) {
winSendKeyEvent(KEY_CapsLock, TRUE);
winSendKeyEvent(KEY_CapsLock, FALSE);
}
- /* Has the key state changed? */
dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
- if (WIN_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
+ if (LOGICAL_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
winSendKeyEvent(KEY_ScrollLock, TRUE);
winSendKeyEvent(KEY_ScrollLock, FALSE);
}
- /* Has the key state changed? */
dwKeyState = GetKeyState(VK_KANA) & 0x0001;
- if (WIN_XOR(internalKeyStates & KanaMask, dwKeyState)) {
+ if (LOGICAL_XOR(internalKeyStates & KanaMask, dwKeyState)) {
winSendKeyEvent(KEY_HKTG, TRUE);
winSendKeyEvent(KEY_HKTG, FALSE);
}