Alexandre Julliard : user32: Retrieve the key state for GetAsyncKeyState from the server.

Alexandre Julliard julliard at winehq.org
Tue Mar 1 11:07:14 CST 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Feb 28 21:55:01 2011 +0100

user32: Retrieve the key state for GetAsyncKeyState from the server.

---

 dlls/user32/driver.c        |    2 +-
 dlls/user32/input.c         |   25 +++++++++++++++++++++----
 dlls/winex11.drv/keyboard.c |   11 ++---------
 dlls/winex11.drv/mouse.c    |   26 --------------------------
 dlls/winex11.drv/x11drv.h   |    1 -
 5 files changed, 24 insertions(+), 41 deletions(-)

diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 5d49882..09dec4f 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -168,7 +168,7 @@ static void CDECL nulldrv_Beep(void)
 
 static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
 {
-    return 0;
+    return -1;
 }
 
 static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index f19b7e4..59cc047 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -300,11 +300,28 @@ HWND WINAPI GetCapture(void)
  * bit set to 1 if currently pressed, low-order bit set to 1 if key has
  * been pressed.
  */
-SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState(INT nKey)
+SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState( INT key )
 {
-    if (nKey < 0 || nKey > 256)
-        return 0;
-    return USER_Driver->pGetAsyncKeyState( nKey );
+    SHORT ret;
+
+    if (key < 0 || key >= 256) return 0;
+
+    if ((ret = USER_Driver->pGetAsyncKeyState( key )) == -1)
+    {
+        ret = 0;
+        SERVER_START_REQ( get_key_state )
+        {
+            req->tid = 0;
+            req->key = key;
+            if (!wine_server_call( req ))
+            {
+                if (reply->state & 0x40) ret |= 0x0001;
+                if (reply->state & 0x80) ret |= 0x8000;
+            }
+        }
+        SERVER_END_REQ;
+    }
+    return ret;
 }
 
 
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index 313ff3a..d99378a 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -65,7 +65,7 @@ WINE_DECLARE_DEBUG_CHANNEL(key);
   0x40 -> key got pressed since last time
   0x01 -> key is toggled
 */
-BYTE key_state_table[256];
+static BYTE key_state_table[256];
 
 static BYTE TrackSysKey = 0; /* determine whether ALT key up will cause a WM_SYSKEYUP
                                 or a WM_KEYUP message */
@@ -1968,16 +1968,9 @@ static BOOL match_x11_keyboard_layout(HKL hkl)
  */
 SHORT CDECL X11DRV_GetAsyncKeyState(INT key)
 {
-    SHORT retval;
-
     /* Photoshop livelocks unless mouse events are included here */
     X11DRV_MsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_KEY | QS_MOUSE, 0 );
-
-    retval = ((key_state_table[key] & 0x40) ? 0x0001 : 0) |
-             ((key_state_table[key] & 0x80) ? 0x8000 : 0);
-    key_state_table[key] &= ~0x40;
-    TRACE_(key)("(%X) -> %x\n", key, retval);
-    return retval;
+    return -1;
 }
 
 
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index e4a6ab5..a675bf7 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -398,58 +398,32 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
         }
     }
     if (flags & MOUSEEVENTF_LEFTDOWN)
-    {
-        key_state_table[VK_LBUTTON] |= 0xc0;
         queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONDOWN : WM_LBUTTONDOWN,
                                  hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_LEFTUP)
-    {
-        key_state_table[VK_LBUTTON] &= ~0x80;
         queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_RBUTTONUP : WM_LBUTTONUP,
                                  hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_RIGHTDOWN)
-    {
-        key_state_table[VK_RBUTTON] |= 0xc0;
         queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONDOWN : WM_RBUTTONDOWN,
                                  hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_RIGHTUP)
-    {
-        key_state_table[VK_RBUTTON] &= ~0x80;
         queue_raw_mouse_message( GetSystemMetrics(SM_SWAPBUTTON) ? WM_LBUTTONUP : WM_RBUTTONUP,
                                  hwnd, pt.x, pt.y, data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_MIDDLEDOWN)
-    {
-        key_state_table[VK_MBUTTON] |= 0xc0;
         queue_raw_mouse_message( WM_MBUTTONDOWN, hwnd, pt.x, pt.y,
                                  data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_MIDDLEUP)
-    {
-        key_state_table[VK_MBUTTON] &= ~0x80;
         queue_raw_mouse_message( WM_MBUTTONUP, hwnd, pt.x, pt.y,
                                  data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_WHEEL)
-    {
         queue_raw_mouse_message( WM_MOUSEWHEEL, hwnd, pt.x, pt.y,
                                  data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_XDOWN)
-    {
-        key_state_table[VK_XBUTTON1 + data - 1] |= 0xc0;
         queue_raw_mouse_message( WM_XBUTTONDOWN, hwnd, pt.x, pt.y,
                                  data, time, extra_info, injected_flags );
-    }
     if (flags & MOUSEEVENTF_XUP)
-    {
-        key_state_table[VK_XBUTTON1 + data - 1] &= ~0x80;
         queue_raw_mouse_message( WM_XBUTTONUP, hwnd, pt.x, pt.y,
                                  data, time, extra_info, injected_flags );
-    }
 }
 
 #ifdef SONAME_LIBXCURSOR
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 3865078..8a75f37 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -609,7 +609,6 @@ extern int alloc_system_colors;
 extern int xrender_error_base;
 extern HMODULE x11drv_module;
 
-extern BYTE key_state_table[256];
 extern POINT cursor_pos;
 
 /* atoms */




More information about the wine-cvs mailing list