From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/input.c | 18 ++++++++++++++++++ dlls/win32u/sysparams.c | 3 +++ dlls/win32u/win32u_private.h | 1 + dlls/wineandroid.drv/keyboard.c | 17 +---------------- dlls/winemac.drv/keyboard.c | 21 +-------------------- dlls/winewayland.drv/wayland_keyboard.c | 18 +----------------- dlls/winex11.drv/keyboard.c | 24 +++--------------------- include/ntuser.h | 6 ++++++ 8 files changed, 34 insertions(+), 74 deletions(-)
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 794dde58359..ba54cd3d7bb 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -989,6 +989,24 @@ BOOL WINAPI NtUserGetKeyboardState( BYTE *state ) return ret; }
+/*********************************************************************** + * get_async_keyboard_state + */ +BOOL get_async_keyboard_state( BYTE state[256] ) +{ + BOOL ret; + + SERVER_START_REQ( get_key_state ) + { + req->async = 1; + req->key = -1; + wine_server_set_reply( req, state, 256 ); + ret = !wine_server_call( req ); + } + SERVER_END_REQ; + return ret; +} + /********************************************************************** * NtUserSetKeyboardState (win32u.@) */ diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9a06db2c7f6..807f2f4ae81 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -6488,6 +6488,9 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) case NtUserCallOneParam_D3DKMTOpenAdapterFromGdiDisplayName: return d3dkmt_open_adapter_from_gdi_display_name( (void *)arg );
+ case NtUserCallOneParam_GetAsyncKeyboardState: + return get_async_keyboard_state( (void *)arg ); + /* temporary exports */ case NtUserGetDeskPattern: return get_entry( &entry_DESKPATTERN, 256, (WCHAR *)arg ); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 0a82c2175ae..fc0f0c62c93 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -96,6 +96,7 @@ extern HWND get_capture(void); extern BOOL get_cursor_pos( POINT *pt ); extern HWND get_focus(void); extern DWORD get_input_state(void); +extern BOOL get_async_keyboard_state( BYTE state[256] ); extern BOOL release_capture(void); extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ); extern BOOL set_caret_blink_time( unsigned int time ); diff --git a/dlls/wineandroid.drv/keyboard.c b/dlls/wineandroid.drv/keyboard.c index b0380d147da..b53bf64abc1 100644 --- a/dlls/wineandroid.drv/keyboard.c +++ b/dlls/wineandroid.drv/keyboard.c @@ -654,21 +654,6 @@ static const char* vkey_to_name( UINT vkey ) return NULL; }
-static BOOL get_async_key_state( BYTE state[256] ) -{ - BOOL ret; - - SERVER_START_REQ( get_key_state ) - { - req->async = 1; - req->key = -1; - wine_server_set_reply( req, state, 256 ); - ret = !wine_server_call( req ); - } - SERVER_END_REQ; - return ret; -} - static void send_keyboard_input( HWND hwnd, WORD vkey, WORD scan, DWORD flags ) { INPUT input; @@ -690,7 +675,7 @@ void update_keyboard_lock_state( WORD vkey, UINT state ) { BYTE keystate[256];
- if (!get_async_key_state( keystate )) return; + if (!NtUserGetAsyncKeyboardState( keystate )) return;
if (!(keystate[VK_CAPITAL] & 0x01) != !(state & AMETA_CAPS_LOCK_ON) && vkey != VK_CAPITAL) { diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 0431cc22150..832e6178466 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1043,25 +1043,6 @@ static void macdrv_send_keyboard_input(HWND hwnd, WORD vkey, WORD scan, unsigned }
-/*********************************************************************** - * get_async_key_state - */ -static BOOL get_async_key_state(BYTE state[256]) -{ - BOOL ret; - - SERVER_START_REQ(get_key_state) - { - req->async = 1; - req->key = -1; - wine_server_set_reply(req, state, 256); - ret = !wine_server_call(req); - } - SERVER_END_REQ; - return ret; -} - - /*********************************************************************** * update_modifier_state */ @@ -1190,7 +1171,7 @@ void macdrv_hotkey_press(const macdrv_event *event) BOOL got_keystate; DWORD flags;
- if ((got_keystate = get_async_key_state(keystate))) + if ((got_keystate = NtUserGetAsyncKeyboardState(keystate))) { update_modifier_state(MOD_ALT, event->hotkey_press.mod_flags, keystate, VK_LMENU, VK_RMENU, 0x38, 0x138, event->hotkey_press.time_ms, FALSE); diff --git a/dlls/winewayland.drv/wayland_keyboard.c b/dlls/winewayland.drv/wayland_keyboard.c index bdef56e8f0c..5c2fe15273e 100644 --- a/dlls/winewayland.drv/wayland_keyboard.c +++ b/dlls/winewayland.drv/wayland_keyboard.c @@ -617,29 +617,13 @@ static BOOL find_xkb_layout_variant(const char *name, const char **layout, const return FALSE; }
-static BOOL get_async_key_state(BYTE state[256]) -{ - BOOL ret; - - SERVER_START_REQ(get_key_state) - { - req->async = 1; - req->key = -1; - wine_server_set_reply(req, state, 256); - ret = !wine_server_call(req); - } - SERVER_END_REQ; - - return ret; -} - static void release_all_keys(HWND hwnd) { BYTE state[256]; int vkey; INPUT input = {.type = INPUT_KEYBOARD};
- get_async_key_state(state); + NtUserGetAsyncKeyboardState(state);
for (vkey = 1; vkey < 256; vkey++) { diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 23f07b851a7..bb5bf6220e1 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1135,24 +1135,6 @@ static void X11DRV_send_keyboard_input( HWND hwnd, WORD vkey, WORD scan, UINT fl }
-/*********************************************************************** - * get_async_key_state - */ -static BOOL get_async_key_state( BYTE state[256] ) -{ - BOOL ret; - - SERVER_START_REQ( get_key_state ) - { - req->async = 1; - req->key = -1; - wine_server_set_reply( req, state, 256 ); - ret = !wine_server_call( req ); - } - SERVER_END_REQ; - return ret; -} - /*********************************************************************** * set_async_key_state */ @@ -1205,7 +1187,7 @@ BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) keymapnotify_hwnd = thread_data->keymapnotify_hwnd; thread_data->keymapnotify_hwnd = NULL;
- if (!get_async_key_state( keystate )) return FALSE; + if (!NtUserGetAsyncKeyboardState( keystate )) return FALSE;
memset(keys, 0, sizeof(keys));
@@ -1292,7 +1274,7 @@ static void adjust_lock_state( BYTE *keystate, HWND hwnd, WORD vkey, WORD scan, * to block changing state, we can't prevent it on X server side. Having * different states would cause us to try to adjust it again on the next * key event. We prevent that by overriding hooks and setting key states here. */ - if (get_async_key_state( keystate ) && (keystate[vkey] & 0x01) == prev_state) + if (NtUserGetAsyncKeyboardState( keystate ) && (keystate[vkey] & 0x01) == prev_state) { WARN("keystate %x not changed (%#.2x), probably blocked by hooks\n", vkey, keystate[vkey]); keystate[vkey] ^= 0x01; @@ -1307,7 +1289,7 @@ static void update_lock_state( HWND hwnd, WORD vkey, UINT state, UINT time ) /* Note: X sets the below states on key down and clears them on key up. Windows triggers them on key down. */
- if (!get_async_key_state( keystate )) return; + if (!NtUserGetAsyncKeyboardState( keystate )) return;
/* Adjust the CAPSLOCK state if it has been changed outside wine */ if (!(keystate[VK_CAPITAL] & 0x01) != !(state & LockMask) && vkey != VK_CAPITAL) diff --git a/include/ntuser.h b/include/ntuser.h index bd11567290f..4148c8cf0b6 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -912,6 +912,7 @@ enum NtUserCallOneParam_SetKeyboardAutoRepeat, NtUserCallOneParam_SetThreadDpiAwarenessContext, NtUserCallOneParam_D3DKMTOpenAdapterFromGdiDisplayName, + NtUserCallOneParam_GetAsyncKeyboardState, /* temporary exports */ NtUserGetDeskPattern, }; @@ -1037,6 +1038,11 @@ static inline NTSTATUS NtUserD3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADA return NtUserCallOneParam( (UINT_PTR)desc, NtUserCallOneParam_D3DKMTOpenAdapterFromGdiDisplayName ); }
+static inline BOOL NtUserGetAsyncKeyboardState( BYTE state[256] ) +{ + return NtUserCallOneParam( (UINT_PTR)state, NtUserCallOneParam_GetAsyncKeyboardState ); +} + /* NtUserCallTwoParam codes, not compatible with Windows */ enum {