aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-15 08:56:37 +0000
committermarha <marha@users.sourceforge.net>2011-03-15 08:56:37 +0000
commit3ab36b2f4665ac51a8a6774fe7151c5cff9bf303 (patch)
treec9f0682ea296e939a8b81e281fdee6538ce8675c /xorg-server
parent01d9c04232c36059c06b7e34b4b00e6a66589e2b (diff)
downloadvcxsrv-3ab36b2f4665ac51a8a6774fe7151c5cff9bf303.tar.gz
vcxsrv-3ab36b2f4665ac51a8a6774fe7151c5cff9bf303.tar.bz2
vcxsrv-3ab36b2f4665ac51a8a6774fe7151c5cff9bf303.zip
Solved problem of GetKeyState not always returning the correct state in WM_SETFOCUS
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/hw/xwin/winkeybd.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 4711a0d96..e53d84b3f 100644
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -276,6 +276,21 @@ winRestoreModeKeyStates (void)
internalKeyStates = 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