From 1bc9c4fdb2e6c2762105c14cdafb7d4ea3370625 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 17 Jun 2019 14:46:20 -0500 Subject: [PATCH] winex11: Update the state of all keys on KeymapNotify. The Binding of Isaac transitions in and out of fullscreen when the "F" key is pressed. Specifically, it will swap states when receiving WM_KEYDOWN, provided that the previous key state was not pressed (i.e. bit 30 is 0). However, as part of the process of transitioning, it hides and shows its window, causing it to temporarily lose focus. If the F key is released while the window does not have focus, Wine misses this fact, and thinks that the key was already pressed the next time it is pressed, causing the game to refuse to change focus. Windows will not deliver WM_KEYUP messages to a window that does not have focus, but it will always report the true previous state of any key on the keyboard when requested. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/winex11.drv/keyboard.c | 55 ++++++++----------------------------- 1 file changed, 11 insertions(+), 44 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index b063491ad5b..131c5f5442f 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1212,13 +1212,12 @@ BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) BOOL changed = FALSE; struct { WORD vkey; - BOOL pressed; - } modifiers[6]; /* VK_LSHIFT through VK_RMENU are contiguous */ - BOOL lwin_pressed = FALSE, rwin_pressed = FALSE; + WORD pressed; + } keys[256]; if (!get_async_key_state( keystate )) return FALSE; - memset(modifiers, 0, sizeof(modifiers)); + memset(keys, 0, sizeof(keys)); EnterCriticalSection( &kbd_section ); @@ -1229,59 +1228,27 @@ BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) { for (j = 0; j < 8; j++) { - int m; - vkey = keyc2vkey[(i * 8) + j]; - switch(vkey & 0xff) - { - case VK_LMENU: - case VK_RMENU: - case VK_LCONTROL: - case VK_RCONTROL: - case VK_LSHIFT: - case VK_RSHIFT: - m = (vkey & 0xff) - VK_LSHIFT; - /* Take the vkey from the first keycode we encounter for this modifier */ - if (!modifiers[m].vkey) modifiers[m].vkey = vkey; - if (event->xkeymap.key_vector[i] & (1<xkeymap.key_vector[i] & (1<xkeymap.key_vector[i] & (1<xkeymap.key_vector[i] & (1<