From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/user32/tests/input.c | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index f92b839f1cb..801e496b7fa 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -3836,6 +3836,18 @@ static LRESULT CALLBACK mouse_move_wndproc(HWND hwnd, UINT msg, WPARAM wparam, L return DefWindowProcW(hwnd, msg, wparam, lparam); }
+static HANDLE mouse_move_event; + +static LRESULT CALLBACK mouse_move_wndproc2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if (msg == WM_MOUSEMOVE || msg == WM_NCMOUSEMOVE) + { + SetEvent(mouse_move_event); + } + + return DefWindowProcW(hwnd, msg, wparam, lparam); +} + static void test_Input_mouse(void) { BOOL got_button_down, got_button_up; @@ -3846,6 +3858,8 @@ static void test_Input_mouse(void) POINT pt, pt_org; MSG msg; BOOL ret; + int timeout; + DWORD end_time;
SetLastError(0xdeadbeef); ret = GetCursorPos(NULL); @@ -4008,6 +4022,7 @@ static void test_Input_mouse(void) } SetEvent(thread_data.end_event); WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); todo_wine ok(hittest_no > 50, "expected loop with WM_NCHITTEST messages\n"); ok(!got_button_down, "unexpected WM_LBUTTONDOWN message\n"); ok(!got_button_up, "unexpected WM_LBUTTONUP message\n"); @@ -4101,6 +4116,55 @@ static void test_Input_mouse(void) GetCursorPos(&pt); ok(pt.x == 200 && pt.y == 200, "GetCursorPos returned %ldx%ld, expected 200x200\n", pt.x, pt.y);
+ /* move mouse over two windows where thread input queues are attached */ + SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); + SetCursorPos(500, 500); + thread_data.start_event = CreateEventA(NULL, FALSE, FALSE, NULL); + ok(thread_data.start_event != NULL, "CreateEvent failed\n"); + thread_data.end_event = CreateEventA(NULL, FALSE, FALSE, NULL); + ok(thread_data.end_event != NULL, "CreateEvent failed\n"); + mouse_move_event = CreateEventA(NULL, TRUE, FALSE, NULL); + thread = CreateThread(NULL, 0, create_static_win, &thread_data, 0, &thread_id); + ok(thread != NULL, "CreateThread failed\n"); + WaitForSingleObject(thread_data.start_event, INFINITE); + SetWindowLongPtrA(thread_data.win, GWLP_WNDPROC, (LONG_PTR)mouse_move_wndproc2); + ok(AttachThreadInput(thread_id, GetCurrentThreadId(), TRUE), + "AttachThreadInput failed\n"); + SetWindowPos(hwnd, NULL, 200, 200, 0, 0, SWP_NOSIZE); + while (wait_for_message(&msg)) DispatchMessageA(&msg); + pt.x = pt.y = 50; + ClientToScreen(hwnd, &pt); + SetCursorPos(pt.x, pt.y); + + timeout = 5000; + end_time = GetTickCount() + timeout; + do + { + if(MsgWaitForMultipleObjects(1, &mouse_move_event, FALSE, timeout, QS_ALLINPUT) == WAIT_OBJECT_0) break; + if(PeekMessageA(&msg, NULL, 0, 0, PM_NOREMOVE)) { + if(!GetMessageA(&msg, NULL, 0, 0)) break; + DispatchMessageA(&msg); + + if(msg.message == WM_MOUSEMOVE || msg.message == WM_NCMOUSEMOVE) + { + pt.x = pt.y = 50; + ClientToScreen(thread_data.win, &pt); + SetCursorPos(pt.x, pt.y); + } + } + timeout = end_time - GetTickCount(); + }while(timeout > 0); + + todo_wine + ok(WaitForSingleObject(mouse_move_event, 0) == WAIT_OBJECT_0, "Timed out waiting for mouse move event\n"); + SetEvent(thread_data.end_event); + wait_for_event(thread, INFINITE); + DestroyWindow(thread_data.win); + CloseHandle(thread_data.start_event); + CloseHandle(thread_data.end_event); + CloseHandle(mouse_move_event); + CloseHandle(thread); + SetCursorPos(pt_org.x, pt_org.y); empty_message_queue(); DestroyWindow(hwnd);