aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winkeybd.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-11-29 07:56:51 +0100
committermarha <marha@users.sourceforge.net>2012-11-29 07:56:51 +0100
commitd2d73da59e64acdc4718e4e6790a69d967bee875 (patch)
tree5c0148abbbb1473bb80ddc7da286beae9c1f2c3d /xorg-server/hw/xwin/winkeybd.c
parent38eb7612c4b39dd69df4baf4450ba512e888effa (diff)
downloadvcxsrv-d2d73da59e64acdc4718e4e6790a69d967bee875.tar.gz
vcxsrv-d2d73da59e64acdc4718e4e6790a69d967bee875.tar.bz2
vcxsrv-d2d73da59e64acdc4718e4e6790a69d967bee875.zip
fontconfig xserver mesa git update 29 nov 2012
xserver: 1712a45422a63f11b2146541279616fcfda09ec6 fontconfig: faea1cac85ac3b0fd6a983e1c0adeb68e115e06c mesa: c1023608002c985b9d72edc64732cd666de2a206
Diffstat (limited to 'xorg-server/hw/xwin/winkeybd.c')
-rw-r--r--xorg-server/hw/xwin/winkeybd.c47
1 files changed, 34 insertions, 13 deletions
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 2ffb9a943..a70cdcd16 100644
--- 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];
/*
@@ -259,36 +262,54 @@ winRestoreModeKeyStates(void)
XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
- /*
- * 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.
- */
+ /* 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 (LOGICAL_XOR(internalKeyStates & ControlMask, ctrl))
+ winSendKeyEvent(KEY_LCtrl, ctrl);
+
+ if (LOGICAL_XOR(internalKeyStates & ShiftMask, shift))
+ winSendKeyEvent(KEY_ShiftL, shift);
- /* Has the key state changed? */
+ if (LOGICAL_XOR(internalKeyStates & Mod1Mask, alt))
+ winSendKeyEvent(KEY_Alt, alt);
+
+ if (LOGICAL_XOR(internalKeyStates & Mod5Mask, altgr))
+ winSendKeyEvent(KEY_AltLang, altgr);
+ }
+
+ /*
+ 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);
}