Hello everyone,
    This is my first patch to wine, which has been submitting since the last 
day. Please help that what is the safe way sending patches that makes sure the 
patch is not corrupt by my mail client? Is it the most correct way to attach a 
path with .txt suffix rather than past inline? Or which mail client should I 
use that may avoid this problem? Thunderbird wraps long lines and join lines 
terminating with a space, I have to manually correct that, it does slows me 
down.
Thanks.
Guo Jian

A window will lose capture if it's disabled, but it's children should
not. Related to bug 33542.
The test is to show that mouse capture of a window is lost when disabling its 
parent window.
It has been tested fine with newtestbot.

---
 dlls/user32/tests/win.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)


diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 37d210e..7c6654d 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3105,6 +3105,86 @@ static void test_capture_4(void)
     DestroyWindow(hwnd);
 }
 
+/* test for that disabling a window should not release capture of child window */
+static void test_capture_5(void)
+{
+    HWND hwnd, child, cap;
+    POINT pnt;
+    MSG msg;
+    BOOL received_lbuttonup_flag;
+    WNDCLASS class;
+
+    class.style         = CS_HREDRAW | CS_VREDRAW;
+    class.lpfnWndProc   = DefWindowProcA;
+    class.cbClsExtra    = 0;
+    class.cbWndExtra    = 0;
+    class.hInstance     = 0;
+    class.hIcon         = NULL;
+    class.hCursor       = NULL;
+    class.hbrBackground = GetStockObject(WHITE_BRUSH);
+    class.lpszMenuName  = 0;
+    class.lpszClassName = "test_capture_5_class";
+    if (!RegisterClass (&class))
+    {
+        ok(FALSE, "RegisterClass failed\n");
+        return;
+    }
+
+    hwnd = CreateWindowEx(0, "test_capture_5_class", "test_capture_5 parent",
+                          WS_OVERLAPPEDWINDOW,
+                          100, 100, 200, 200,
+                          0, 0, GetModuleHandle(0), NULL);
+    assert(hwnd);
+    trace("hwnd %p\n", hwnd);
+    child = CreateWindowExA(0, "Edit", "child",
+                            WS_BORDER | WS_CHILD | WS_VISIBLE,
+                            10, 10, 50, 50, hwnd, 0,
+                            GetModuleHandle(0), NULL);
+    assert(child);
+    trace("child %p\n", child);
+
+    ShowWindow(hwnd, SW_SHOW);
+    UpdateWindow(hwnd);
+    ShowWindow(child, SW_SHOW);
+    UpdateWindow(child);
+
+    /* hold left mouse button down in child */
+    pnt.x = pnt.y = 30;
+    ClientToScreen(hwnd, &pnt);
+    SetCursorPos(pnt.x, pnt.y);
+    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
+
+    /* set capture to child */
+    ReleaseCapture();
+    SetCapture(child);
+    cap = GetCapture();
+    ok(cap == child, "SetCapture failed.\n");
+    /* disable the parent window */
+    EnableWindow(hwnd, FALSE);
+    cap = GetCapture();
+    todo_wine ok(cap != NULL, "Capture in child should not be released.\n");
+
+    /* move mouse out and release */
+    SetCursorPos(20, 20);
+    received_lbuttonup_flag = FALSE;
+    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+    flush_events(FALSE);
+
+    /* should receive BUTTONUP message when captured */
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+    {
+        if (msg.message == WM_LBUTTONUP)
+            if (msg.hwnd == child) received_lbuttonup_flag = TRUE;
+        DispatchMessage(&msg);
+    }
+    todo_wine ok(received_lbuttonup_flag, "WM_LBUTTONUP should have been received in child\n");
+    ReleaseCapture();
+
+    /* clean up */
+    DestroyWindow(child);
+    DestroyWindow(hwnd);
+}
+
 /* PeekMessage wrapper that ignores the messages we don't care about */
 static BOOL peek_message( MSG *msg )
 {
@@ -7455,6 +7535,7 @@ START_TEST(win)
     test_capture_2();
     test_capture_3(hwndMain, hwndMain2);
     test_capture_4();
+    test_capture_5();
     test_rtl_layout();
     test_FlashWindowEx();
 



Reply via email to