Vitaliy Margolen : winex11drv: Return cached cursor_pos in GetCursorPos().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Dec 19 10:04:55 CST 2006


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

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Mon Dec 18 13:26:35 2006 -0700

winex11drv: Return cached cursor_pos in GetCursorPos().

---

 dlls/user32/tests/win.c  |    9 +++++++++
 dlls/winex11.drv/mouse.c |   13 ++++++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 4ca0b31..3dde99a 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -2501,6 +2501,15 @@ static void test_mouse_input(HWND hwnd)
     GetCursorPos(&pt);
     ok(x == pt.x && y == pt.y, "wrong cursor pos (%d,%d), expected (%d,%d)\n", pt.x, pt.y, x, y);
 
+    while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
+
+    /* Check that setting the same position will generate WM_MOUSEMOVE */
+    SetCursorPos(x, y);
+    msg.message = 0;
+    ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
+    ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
+    ok(msg.pt.x == x && msg.pt.y == y, "wrong message coords (%d,%d)/(%d,%d)\n", x, y, msg.pt.x, msg.pt.y);
+
     /* force the system to update its internal queue mouse position,
      * otherwise it won't generate relative mouse movements below.
      */
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index a9a4a8d..e8ae64f 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -70,6 +70,7 @@ static const UINT button_up_flags[NB_BUT
 };
 
 POINT cursor_pos;
+static DWORD last_time_modified;
 
 BOOL X11DRV_SetCursorPos( INT x, INT y );
 
@@ -190,6 +191,7 @@ static void queue_raw_mouse_message( UIN
     hook.time        = time;
     hook.dwExtraInfo = extra_info;
 
+    last_time_modified = GetTickCount();
     if (HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, message, (LPARAM)&hook, TRUE )) return;
 
     SERVER_START_REQ( send_hardware_message )
@@ -685,6 +687,14 @@ BOOL X11DRV_SetCursorPos( INT x, INT y )
     TRACE( "warping to (%d,%d)\n", x, y );
 
     wine_tsx11_lock();
+    if (cursor_pos.x == x && cursor_pos.y == y)
+    {
+        wine_tsx11_unlock();
+        /* We still need to generate WM_MOUSEMOVE */
+        queue_raw_mouse_message( WM_MOUSEMOVE, NULL, x, y, 0, GetCurrentTime(), 0, 0 );
+        return TRUE;
+    }
+
     XWarpPointer( display, root_window, root_window, 0, 0, 0, 0,
                   x - virtual_screen_rect.left, y - virtual_screen_rect.top );
     XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */
@@ -705,7 +715,8 @@ BOOL X11DRV_GetCursorPos(LPPOINT pos)
     unsigned int xstate;
 
     wine_tsx11_lock();
-    if (XQueryPointer( display, root_window, &root, &child,
+    if ((GetTickCount() - last_time_modified > 100) &&
+        XQueryPointer( display, root_window, &root, &child,
                        &rootX, &rootY, &winX, &winY, &xstate ))
     {
         update_button_state( xstate );




More information about the wine-cvs mailing list