hw/xwin: Restore non-latching modifier key state when an X window gains focus
In multiwindow mode, the state of the modifier keys was lost when a window is created (or raised) and focus moved to that window. For example: In window A Ctrl + some key opens a window B, then in window B Ctrl + some other key triggers the next action. However after the opening of window B the Ctrl key has to be released and pressed again. If the user keeps the Ctrl key held down when the window B is opened, the next key press X will be interpreted as X and not as Ctrl+X. Extended the function winRestoreModeKeyStates in winkeybd.c to consider not only the latching modifier keys but also the modifiers Ctrl, Shift, Alt/AltGr by using the Windows function GetAsyncKeyState. A combined Ctrl+AltGr modifier state cannot be restored correctly, as Windows always fakes a Ctrl-L when AltGr is pressed. Signed-off-by: Oliver Schmidt <oschmidt-mailinglists@gmx.de> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
47291d0b7d
commit
11bb32e561
|
@ -262,6 +262,28 @@ winRestoreModeKeyStates(void)
|
|||
XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
|
||||
winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
|
||||
|
||||
/* 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);
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user