Add a mouse input test case, make the test pass under Wine
Dmitry Timoshkov
dmitry at baikal.ru
Wed Oct 20 05:46:09 CDT 2004
Hello,
please apply after the window visibility fix in the wineserver.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Add a mouse input test case, make the test pass under Wine.
diff -u cvs/hq/wine/dlls/user/tests/win.c wine/dlls/user/tests/win.c
--- cvs/hq/wine/dlls/user/tests/win.c 2004-10-12 08:51:47.000000000 +0900
+++ wine/dlls/user/tests/win.c 2004-10-20 19:15:33.000000000 +0900
@@ -2099,6 +2099,63 @@ static void test_keyboard_input(HWND hwn
ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
}
+static void test_mouse_input(HWND hwnd)
+{
+ RECT rc;
+ POINT pt;
+ int x, y;
+ HWND popup;
+ MSG msg;
+
+ ShowWindow(hwnd, SW_SHOW);
+ UpdateWindow(hwnd);
+
+ GetWindowRect(hwnd, &rc);
+ trace("main window %p: (%ld,%ld)-(%ld,%ld)\n", hwnd, rc.left, rc.top, rc.right, rc.bottom);
+
+ popup = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP,
+ rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
+ hwnd, 0, 0, NULL);
+ assert(popup != 0);
+ ShowWindow(popup, SW_SHOW);
+ UpdateWindow(popup);
+
+ GetWindowRect(popup, &rc);
+ trace("popup window %p: (%ld,%ld)-(%ld,%ld)\n", popup, rc.left, rc.top, rc.right, rc.bottom);
+
+ x = rc.left + (rc.right - rc.left) / 2;
+ y = rc.top + (rc.bottom - rc.top) / 2;
+ trace("setting cursor to (%d,%d)\n", x, y);
+
+ SetCursorPos(x, y);
+ GetCursorPos(&pt);
+ ok(x == pt.x && y == pt.y, "wrong cursor pos (%ld,%ld), expected (%d,%d)\n", pt.x, pt.y, x, y);
+
+ /* force the system to update its internal queue mouse position,
+ * otherwise it won't generate relative mouse movements below.
+ */
+ mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
+ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
+
+ msg.message = 0;
+ mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 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(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+
+ mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
+ ShowWindow(popup, SW_HIDE);
+ ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "no message available\n");
+ ok(msg.hwnd == hwnd && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
+ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
+
+ mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
+ ShowWindow(hwnd, SW_HIDE);
+ ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "message %04x available\n", msg.message);
+
+ DestroyWindow(popup);
+}
+
START_TEST(win)
{
pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -2153,6 +2210,7 @@ START_TEST(win)
test_children_zorder(hwndMain);
test_keyboard_input(hwndMain);
+ test_mouse_input(hwndMain);
UnhookWindowsHookEx(hhook);
}
diff -u cvs/hq/wine/dlls/x11drv/mouse.c wine/dlls/x11drv/mouse.c
--- cvs/hq/wine/dlls/x11drv/mouse.c 2003-11-22 21:56:12.000000000 +0800
+++ wine/dlls/x11drv/mouse.c 2004-10-20 18:52:10.000000000 +0900
@@ -605,6 +605,8 @@ void X11DRV_MotionNotify( HWND hwnd, XMo
{
POINT pt;
+ TRACE("hwnd %p, event->is_hint %d\n", hwnd, event->is_hint);
+
if (!hwnd) return;
update_cursor( hwnd, event->window );
@@ -622,8 +624,10 @@ void X11DRV_EnterNotify( HWND hwnd, XCro
{
POINT pt;
- if (event->detail == NotifyVirtual || event->detail == NotifyNonlinearVirtual) return;
+ TRACE("hwnd %p, event->detail %d\n", hwnd, event->detail);
+
if (!hwnd) return;
+ if (event->detail == NotifyVirtual || event->detail == NotifyNonlinearVirtual) return;
/* simulate a mouse motion event */
update_cursor( hwnd, event->window );
diff -u cvs/hq/wine/windows/input.c wine/windows/input.c
--- cvs/hq/wine/windows/input.c 2004-09-02 17:23:57.000000000 +0900
+++ wine/windows/input.c 2004-10-20 19:24:19.000000000 +0900
@@ -279,7 +279,10 @@ static void queue_mouse_event( const MOU
else PosY = posY;
}
- if (mi->dwFlags & MOUSEEVENTF_MOVE)
+ /* LLMHF_INJECTED will cause SetCursorPos below to generate
+ * a mouse move event.
+ */
+ if ((mi->dwFlags & MOUSEEVENTF_MOVE) && !(flags & LLMHF_INJECTED))
{
queue_raw_mouse_message( WM_MOUSEMOVE, flags, PosX, PosY, mi );
}
More information about the wine-patches
mailing list