Commit 7de64a3a authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

winex11drv: Return cached cursor_pos in GetCursorPos().

parent 84f0a035
......@@ -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.
*/
......
......@@ -70,6 +70,7 @@ static const UINT button_up_flags[NB_BUTTONS] =
};
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( UINT message, HWND hwnd, DWORD x, DWORD y,
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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment