hw/xwin: Give our logical xor operator a more logical name
Also, rather than a comment about why we need a logical operator, let's have a comment about what we are doing to the keyboard state... Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
8aa27ae821
commit
47291d0b7d
|
@ -248,9 +248,6 @@ if (++PROFPT##point % thresh == 0)\
|
||||||
ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
|
ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We use xor this macro for detecting toggle key state changes */
|
|
||||||
#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
|
|
||||||
|
|
||||||
#define DEFINE_ATOM_HELPER(func,atom_name) \
|
#define DEFINE_ATOM_HELPER(func,atom_name) \
|
||||||
static Atom func (void) { \
|
static Atom func (void) { \
|
||||||
static int generation; \
|
static int generation; \
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
|
|
||||||
#include "xkbsrv.h"
|
#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];
|
static Bool g_winKeyState[NUM_KEYCODES];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -259,36 +262,32 @@ winRestoreModeKeyStates(void)
|
||||||
XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
|
XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
|
||||||
winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
|
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* 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;
|
dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001;
|
||||||
if (WIN_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
|
if (LOGICAL_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
|
||||||
winSendKeyEvent(KEY_NumLock, TRUE);
|
winSendKeyEvent(KEY_NumLock, TRUE);
|
||||||
winSendKeyEvent(KEY_NumLock, FALSE);
|
winSendKeyEvent(KEY_NumLock, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Has the key state changed? */
|
|
||||||
dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
|
dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
|
||||||
if (WIN_XOR(internalKeyStates & LockMask, dwKeyState)) {
|
if (LOGICAL_XOR(internalKeyStates & LockMask, dwKeyState)) {
|
||||||
winSendKeyEvent(KEY_CapsLock, TRUE);
|
winSendKeyEvent(KEY_CapsLock, TRUE);
|
||||||
winSendKeyEvent(KEY_CapsLock, FALSE);
|
winSendKeyEvent(KEY_CapsLock, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Has the key state changed? */
|
|
||||||
dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
|
dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
|
||||||
if (WIN_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
|
if (LOGICAL_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
|
||||||
winSendKeyEvent(KEY_ScrollLock, TRUE);
|
winSendKeyEvent(KEY_ScrollLock, TRUE);
|
||||||
winSendKeyEvent(KEY_ScrollLock, FALSE);
|
winSendKeyEvent(KEY_ScrollLock, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Has the key state changed? */
|
|
||||||
dwKeyState = GetKeyState(VK_KANA) & 0x0001;
|
dwKeyState = GetKeyState(VK_KANA) & 0x0001;
|
||||||
if (WIN_XOR(internalKeyStates & KanaMask, dwKeyState)) {
|
if (LOGICAL_XOR(internalKeyStates & KanaMask, dwKeyState)) {
|
||||||
winSendKeyEvent(KEY_HKTG, TRUE);
|
winSendKeyEvent(KEY_HKTG, TRUE);
|
||||||
winSendKeyEvent(KEY_HKTG, FALSE);
|
winSendKeyEvent(KEY_HKTG, FALSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue