Race condition in keyboard code?

Peter Åstrand astrand at cendio.se
Fri Mar 24 02:45:06 CST 2006

On Fri, 24 Mar 2006, Dmitry Timoshkov wrote:

>> ? I do understand why this happens: X11DRV_ToUnicodeEx uses the global,
>> static variable AltGrMask. Is this a bug?
> In X11DRV_ToUnicodeEx we need to restore XKeyEvent from the previous
> KeyPress event. If you have a better idea how to do it without using
> global variables please let us know.

What about using the thread_input->keystate, just as for Shift, Control, 
and NumLock?

ToUnicodeEx does have a lpKeyState argument, so to me, it seems very wrong 
that a static, global variable is needed as well.

TranslateMessage calls GetKeyboardState just before ToUnicode. MSDN 
documents GetKeyboardState as: "The status changes as a thread removes 
keyboard messages from its message queue." My interpretation is that this 
means that ToUnicodeEx consider how the modifiers *was* rather then what 
they *are*.

The current implementation has another drawback: AltGr key presses never 
reaches the applications. In Windows, applications recieves VK_CONTROL, 
VK_MENU when AltGr is pressed.

Peter Åstrand		ThinLinc Chief Developer
Cendio			http://www.cendio.se
Teknikringen 3
583 30 Linköping        Phone: +46-13-21 46 00

More information about the wine-devel mailing list