Jacek Caban : win32u: Move NtUserGetKeyState implementation from user32.

Alexandre Julliard julliard at winehq.org
Tue Nov 16 16:32:27 CST 2021


Module: wine
Branch: master
Commit: d99f61dd9aa218ffb24f301a518fe659af9ee672
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d99f61dd9aa218ffb24f301a518fe659af9ee672

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Nov 16 12:33:09 2021 +0100

win32u: Move NtUserGetKeyState implementation from user32.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/defwnd.c    |  4 ++--
 dlls/user32/dialog.c    |  4 ++--
 dlls/user32/edit.c      |  8 ++++----
 dlls/user32/input.c     | 22 ----------------------
 dlls/user32/listbox.c   |  2 +-
 dlls/user32/mdi.c       |  4 ++--
 dlls/user32/menu.c      |  6 +++---
 dlls/user32/user32.spec |  2 +-
 dlls/user32/win.c       |  2 +-
 dlls/win32u/input.c     | 24 ++++++++++++++++++++++++
 dlls/win32u/syscall.c   |  1 +
 dlls/win32u/win32u.spec |  2 +-
 dlls/wow64win/syscall.h |  1 +
 dlls/wow64win/user.c    |  7 +++++++
 14 files changed, 50 insertions(+), 39 deletions(-)

diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index 5eb056ebd9e..916029c2579 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -507,11 +507,11 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
         }
         else if( wParam == VK_F10 )
         {
-            if (GetKeyState(VK_SHIFT) & 0x8000)
+            if (NtUserGetKeyState(VK_SHIFT) & 0x8000)
                 SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, -1 );
             iF10Key = 1;
         }
-        else if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
+        else if (wParam == VK_ESCAPE && (NtUserGetKeyState(VK_SHIFT) & 0x8000))
             SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
         break;
 
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index c48f404eceb..7fac3e6b44c 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1198,7 +1198,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
                  * do so but I presume someone has)
                  */
                 if (fIsDialog)
-                    SendMessageW( hwndDlg, WM_NEXTDLGCTL, (GetKeyState(VK_SHIFT) & 0x8000), 0 );
+                    SendMessageW( hwndDlg, WM_NEXTDLGCTL, (NtUserGetKeyState(VK_SHIFT) & 0x8000), 0 );
                 else
                 {
                     /* It would appear that GetNextDlgTabItem can handle being
@@ -1208,7 +1208,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
                     HWND hwndFocus = GetFocus();
                     HWND hwndNext = GetNextDlgTabItem (hwndDlg,
                             hwndFocus == hwndDlg ? NULL : hwndFocus,
-                            GetKeyState (VK_SHIFT) & 0x8000);
+                            NtUserGetKeyState (VK_SHIFT) & 0x8000);
                     if (hwndNext)
                     {
                         dlgCode = SendMessageW (hwndNext, WM_GETDLGCODE,
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index cf5e807de21..73885566d3b 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -3176,7 +3176,7 @@ static LRESULT EDIT_WM_Char(EDITSTATE *es, WCHAR c)
 {
         BOOL control;
 
-	control = GetKeyState(VK_CONTROL) & 0x8000;
+	control = NtUserGetKeyState(VK_CONTROL) & 0x8000;
 
 	switch (c) {
 	case '\r':
@@ -3436,11 +3436,11 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
 	BOOL shift;
 	BOOL control;
 
-	if (GetKeyState(VK_MENU) & 0x8000)
+	if (NtUserGetKeyState(VK_MENU) & 0x8000)
 		return 0;
 
-	shift = GetKeyState(VK_SHIFT) & 0x8000;
-	control = GetKeyState(VK_CONTROL) & 0x8000;
+	shift = NtUserGetKeyState(VK_SHIFT) & 0x8000;
+	control = NtUserGetKeyState(VK_CONTROL) & 0x8000;
 
 	switch (key) {
 	case VK_F4:
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 1362664d0c9..7d0581dfc8f 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -593,28 +593,6 @@ BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO plii)
 }
 
 
-/**********************************************************************
- *		GetKeyState (USER32.@)
- *
- * An application calls the GetKeyState function in response to a
- * keyboard-input message.  This function retrieves the state of the key
- * at the time the input message was generated.
- */
-SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState(INT vkey)
-{
-    SHORT retval = 0;
-
-    SERVER_START_REQ( get_key_state )
-    {
-        req->key = vkey;
-        if (!wine_server_call( req )) retval = (signed char)(reply->state & 0x81);
-    }
-    SERVER_END_REQ;
-    TRACE("key (0x%x) -> %x\n", vkey, retval);
-    return retval;
-}
-
-
 /**********************************************************************
  *		GetKeyboardState (USER32.@)
  */
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 912adb716d0..c7e97170b27 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -2508,7 +2508,7 @@ static LRESULT LISTBOX_HandleKeyDown( LB_DESCR *descr, DWORD key )
     if (caret >= 0)
     {
         if (((descr->style & LBS_EXTENDEDSEL) &&
-            !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
+            !(NtUserGetKeyState( VK_SHIFT ) & 0x8000)) ||
             !IS_MULTISELECT(descr))
             descr->anchor_item = caret;
         LISTBOX_MoveCaret( descr, caret, TRUE );
diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c
index af39e5781ed..1047b969c17 100644
--- a/dlls/user32/mdi.c
+++ b/dlls/user32/mdi.c
@@ -1649,13 +1649,13 @@ BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg )
 
         /* translate if the Ctrl key is down and Alt not. */
 
-        if( (GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
+        if( (NtUserGetKeyState(VK_CONTROL) & 0x8000) && !(NtUserGetKeyState(VK_MENU) & 0x8000))
         {
             switch( msg->wParam )
             {
             case VK_F6:
             case VK_TAB:
-                wParam = ( GetKeyState(VK_SHIFT) & 0x8000 ) ? SC_NEXTWINDOW : SC_PREVWINDOW;
+                wParam = ( NtUserGetKeyState(VK_SHIFT) & 0x8000 ) ? SC_NEXTWINDOW : SC_PREVWINDOW;
                 break;
             case VK_F4:
             case VK_RBUTTON:
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index ec6ff1d0dd0..f0d4be8a684 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -5505,9 +5505,9 @@ static BOOL translate_accelerator( HWND hWnd, UINT message, WPARAM wParam, LPARA
 
     if (wParam != key) return FALSE;
 
-    if (GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
-    if (GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
-    if (GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
+    if (NtUserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
+    if (NtUserGetKeyState(VK_MENU) & 0x8000) mask |= FALT;
+    if (NtUserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
 
     if (message == WM_CHAR || message == WM_SYSCHAR)
     {
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index 34ba824dc38..91dc9674a3b 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -316,7 +316,7 @@
 @ stdcall GetKBCodePage()
 @ stdcall GetKeyNameTextA(long ptr long)
 @ stdcall GetKeyNameTextW(long ptr long)
-@ stdcall GetKeyState(long)
+@ stdcall -import GetKeyState(long) NtUserGetKeyState
 @ stdcall GetKeyboardLayout(long)
 @ stdcall GetKeyboardLayoutList(long ptr)
 @ stdcall GetKeyboardLayoutNameA(ptr)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index bc0b06c3f94..9fd5a9aa5e6 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3893,7 +3893,7 @@ BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
 
     TRACE( "%p,%s\n", hWnd, wine_dbgstr_point( &pt ) );
 
-    if (!(GetKeyState( VK_LBUTTON ) & 0x8000))
+    if (!(NtUserGetKeyState( VK_LBUTTON ) & 0x8000))
         return FALSE;
 
     wDragWidth = GetSystemMetrics(SM_CXDRAG);
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c
index 0a4ebdace1d..5383115a424 100644
--- a/dlls/win32u/input.c
+++ b/dlls/win32u/input.c
@@ -28,6 +28,9 @@
 
 #include "win32u_private.h"
 #include "wine/server.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(win);
 
 
 /**********************************************************************
@@ -47,3 +50,24 @@ BOOL WINAPI NtUserAttachThreadInput( DWORD from, DWORD to, BOOL attach )
     SERVER_END_REQ;
     return ret;
 }
+
+/**********************************************************************
+ *	     NtUserGetKeyState    (win32u.@)
+ *
+ * An application calls the GetKeyState function in response to a
+ * keyboard-input message.  This function retrieves the state of the key
+ * at the time the input message was generated.
+ */
+SHORT WINAPI NtUserGetKeyState( INT vkey )
+{
+    SHORT retval = 0;
+
+    SERVER_START_REQ( get_key_state )
+    {
+        req->key = vkey;
+        if (!wine_server_call( req )) retval = (signed char)(reply->state & 0x81);
+    }
+    SERVER_END_REQ;
+    TRACE("key (0x%x) -> %x\n", vkey, retval);
+    return retval;
+}
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c
index e557eade893..9216e95f25c 100644
--- a/dlls/win32u/syscall.c
+++ b/dlls/win32u/syscall.c
@@ -111,6 +111,7 @@ static void * const syscalls[] =
     NtUserGetClipboardOwner,
     NtUserGetClipboardSequenceNumber,
     NtUserGetClipboardViewer,
+    NtUserGetKeyState,
     NtUserGetLayeredWindowAttributes,
     NtUserGetObjectInformation,
     NtUserGetProcessWindowStation,
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 2a627763091..2003dc39bcd 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -945,7 +945,7 @@
 @ stub NtUserGetInteractiveCtrlSupportedWaveforms
 @ stub NtUserGetInternalWindowPos
 @ stub NtUserGetKeyNameText
-@ stub NtUserGetKeyState
+@ stdcall -syscall NtUserGetKeyState(long)
 @ stub NtUserGetKeyboardLayout
 @ stub NtUserGetKeyboardLayoutList
 @ stub NtUserGetKeyboardLayoutName
diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h
index 4f7ff8e003c..7dc791e8eb5 100644
--- a/dlls/wow64win/syscall.h
+++ b/dlls/wow64win/syscall.h
@@ -98,6 +98,7 @@
     SYSCALL_ENTRY( NtUserGetClipboardOwner ) \
     SYSCALL_ENTRY( NtUserGetClipboardSequenceNumber ) \
     SYSCALL_ENTRY( NtUserGetClipboardViewer ) \
+    SYSCALL_ENTRY( NtUserGetKeyState ) \
     SYSCALL_ENTRY( NtUserGetLayeredWindowAttributes ) \
     SYSCALL_ENTRY( NtUserGetObjectInformation ) \
     SYSCALL_ENTRY( NtUserGetProcessWindowStation ) \
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c
index a783eb42229..dcf8850c3f2 100644
--- a/dlls/wow64win/user.c
+++ b/dlls/wow64win/user.c
@@ -237,3 +237,10 @@ NTSTATUS WINAPI wow64_NtUserAttachThreadInput( UINT *args )
 
     return NtUserAttachThreadInput( from, to, attach );
 }
+
+NTSTATUS WINAPI wow64_NtUserGetKeyState( UINT *args )
+{
+    INT vkey = get_ulong( &args );
+
+    return NtUserGetKeyState( vkey );
+}




More information about the wine-cvs mailing list