[PATCH 1/3] winex11.drv: do not call hooks from SetCursorPos.

Lauri Kenttä lauri.kentta at gmail.com
Mon Jan 18 17:34:14 CST 2010


When moving the cursor with SetCursorPos, low-level mouse hooks should not
be called. (Tested with Windows 2008 Server.)

This patch fixes the problem in case that SetCursorPos doesn't need to
call XWarpPointer; in the other case, there isn't much we can do, because
the X protocol works asynchronously, but that doesn't cause so many
problems, either.
---
 dlls/winex11.drv/mouse.c |   44 ++++++++++++++++++++++++--------------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 60351e5..b85c71f 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -238,19 +238,22 @@ static WORD get_key_state(void)
  *           queue_raw_mouse_message
  */
 static void queue_raw_mouse_message( UINT message, HWND hwnd, DWORD x, DWORD y,
-                                     DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
+                                     DWORD data, DWORD time, DWORD extra_info, UINT injected_flags,
+                                     BOOL call_hooks )
 {
     MSLLHOOKSTRUCT hook;
 
-    hook.pt.x        = x;
-    hook.pt.y        = y;
-    hook.mouseData   = MAKELONG( 0, data );
-    hook.flags       = injected_flags;
-    hook.time        = time;
-    hook.dwExtraInfo = extra_info;
-
     last_time_modified = GetTickCount();
-    if (HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
+    if (call_hooks) {
+        hook.pt.x        = x;
+        hook.pt.y        = y;
+        hook.mouseData   = MAKELONG( 0, data );
+        hook.flags       = injected_flags;
+        hook.time        = time;
+        hook.dwExtraInfo = extra_info;
+
+        if (HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
+    }
 
     SERVER_START_REQ( send_hardware_message )
     {
@@ -329,7 +332,7 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
     if (flags & MOUSEEVENTF_MOVE)
     {
         queue_raw_mouse_message( WM_MOUSEMOVE, hwnd, pt.x, pt.y, data, time,
-                                 extra_info, injected_flags );
+                                 extra_info, injected_flags, TRUE );
         if ((injected_flags & LLMHF_INJECTED) &&
             ((flags & MOUSEEVENTF_ABSOLUTE) || x || y))  /* we have to actually move the cursor */
         {
@@ -347,54 +350,54 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
     {
         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 );
+                                 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags, TRUE );
     }
     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 );
+                                 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags, TRUE );
     }
     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 );
+                                 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags, TRUE );
     }
     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 );
+                                 hwnd, pt.x, pt.y, data, time, extra_info, injected_flags, TRUE );
     }
     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 );
+                                 extra_info, injected_flags, TRUE );
     }
     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 );
+                                 extra_info, injected_flags, TRUE );
     }
     if (flags & MOUSEEVENTF_WHEEL)
     {
         queue_raw_mouse_message( WM_MOUSEWHEEL, hwnd, pt.x, pt.y, data, time,
-                                 extra_info, injected_flags );
+                                 extra_info, injected_flags, TRUE );
     }
     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 );
+                                 extra_info, injected_flags, TRUE );
     }
     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 );
+                                 extra_info, injected_flags, TRUE );
     }
 }
 
@@ -993,12 +996,13 @@ BOOL CDECL X11DRV_SetCursorPos( INT x, INT y )
     {
         wine_tsx11_unlock();
         /* We still need to generate WM_MOUSEMOVE */
-        queue_raw_mouse_message( WM_MOUSEMOVE, NULL, x, y, 0, GetCurrentTime(), 0, 0 );
+        queue_raw_mouse_message( WM_MOUSEMOVE, NULL, x, y, 0, GetCurrentTime(), 0, 0, FALSE );
         return TRUE;
     }
 
     pt.x = x; pt.y = y;
     clip_point_to_rect( &cursor_clip, &pt);
+    /* FIXME: SetCursorPos shouldn't call hooks, but this one does! */
     XWarpPointer( display, root_window, root_window, 0, 0, 0, 0,
                   pt.x - virtual_screen_rect.left, pt.y - virtual_screen_rect.top );
     XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */
-- 
1.6.6




More information about the wine-patches mailing list