user32: A window may be notified with WM_CAPTURECHANGED about itself if SetCapture...
authorChristopher Thielen <cthielen@gmail.com>
Mon, 1 Feb 2016 04:32:51 +0000 (20:32 -0800)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 2 Feb 2016 13:24:11 +0000 (22:24 +0900)
Signed-off-by: Christopher Thielen <cthielen@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/user32/input.c
dlls/user32/tests/msg.c

index 40e35a9cc20e88155b0a5fe45f5923a72ce6834e..63fae6780134bb9ab07f7f32f1334e423015323f 100644 (file)
@@ -108,7 +108,7 @@ BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret )
     {
         USER_Driver->pSetCapture( hwnd, gui_flags );
 
-        if (previous && previous != hwnd)
+        if (previous)
             SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
 
         if (prev_ret) *prev_ret = previous;
index d20f28b76c561e32c6fedfcf681c3363fd6a15be..9990bccb651e905a5ec6293faa6317aab47048d0 100644 (file)
@@ -15125,6 +15125,33 @@ else
     flush_sequence();
 }
 
+static const struct message DoubleSetCaptureSeq[] =
+{
+    { WM_CAPTURECHANGED, sent },
+    { 0 }
+};
+
+static void test_DoubleSetCapture(void)
+{
+    HWND hwnd;
+
+    hwnd = CreateWindowExA(0, "TestWindowClass", "Test DoubleSetCapture",
+                           WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+                           100, 100, 200, 200, 0, 0, 0, NULL);
+    ok (hwnd != 0, "Failed to create overlapped window\n");
+
+    ShowWindow( hwnd, SW_SHOW );
+    UpdateWindow( hwnd );
+    flush_events();
+    flush_sequence();
+
+    SetCapture( hwnd );
+    SetCapture( hwnd );
+    ok_sequence(DoubleSetCaptureSeq, "SetCapture( hwnd ) twice", FALSE);
+
+    DestroyWindow(hwnd);
+}
+
 static void init_funcs(void)
 {
     HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
@@ -15265,6 +15292,7 @@ START_TEST(msg)
     test_layered_window();
     test_TrackPopupMenu();
     test_TrackPopupMenuEmpty();
+    test_DoubleSetCapture();
     /* keep it the last test, under Windows it tends to break the tests
      * which rely on active/foreground windows being correct.
      */