Add a mouse input test case, make the test pass under Wine. Take 2

Dmitry Timoshkov dmitry at baikal.ru
Wed Dec 15 07:49:48 CST 2004


Hello,

here is a test case for a wineserver window visibility fix committed
long time ago.

This is the same patch as before but with the test adapted for Wine
specific behaviour of SetCursorPos (it injects an additional WM_MOUSEMOVE
message). Alexandre is right that Wine could be fixed later on once
an application that depends on it is found.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Add a mouse input test case, make the test pass under Wine.

diff -up 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-12-15 21:35:23.000000000 +0800
@@ -2099,6 +2099,66 @@ 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);
+    /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
+    if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
+        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 +2213,7 @@ START_TEST(win)
 
     test_children_zorder(hwndMain);
     test_keyboard_input(hwndMain);
+    test_mouse_input(hwndMain);
 
     UnhookWindowsHookEx(hhook);
 }
diff -up 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-12-15 21:28:11.000000000 +0800
@@ -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 );






More information about the wine-patches mailing list