[PATCH] user32: Allow WM_CAPTURECHANGE indicating SetCapture() parameter.
Christopher Thielen
cthielen at gmail.com
Mon Nov 23 00:52:53 CST 2015
Fixes https://bugs.winehq.org/show_bug.cgi?id=13683
A window may be notified with WM_CAPTURECHANGED about itself
gaining mouse capture if it calls SetCapture() twice.
Tested on Windows XP and Fedora Workstation 22.
Signed-off-by: Christopher Thielen <cthielen at gmail.com>
---
dlls/user32/input.c | 2 +-
dlls/user32/tests/msg.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 40e35a9..63fae67 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -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;
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index d92fbc7..8ac3239 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -14906,6 +14906,35 @@ else
flush_sequence();
}
+// Not const in order to set lParam during test
+static struct message DoubleSetCaptureSeq[] =
+{
+ { WM_CAPTURECHANGED, sent|wparam|lparam, 0, 1 },
+ { 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");
+ DoubleSetCaptureSeq[0].lParam = (LPARAM)hwnd;
+ ShowWindow( hwnd, SW_SHOW );
+ flush_sequence();
+
+ trace("SetCapture( hwnd )\n");
+ SetCapture( hwnd );
+ trace("SetCapture( hwnd )\n");
+ SetCapture( hwnd );
+ ok_sequence(DoubleSetCaptureSeq, "SetCapture( hwnd ) twice", FALSE);
+ trace("done\n");
+
+ DestroyWindow(hwnd);
+}
+
static void init_funcs(void)
{
HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
@@ -15045,6 +15074,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.
*/
--
2.4.3
More information about the wine-patches
mailing list