[PATCH v4 3/7] user32: Don't call ReleaseCapture() in EnableWindow().

Zebediah Figura z.figura12 at gmail.com
Mon Mar 27 14:01:40 CDT 2017


Killing the capture is already handled in DefWindowProc(), as in Windows.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/user32/tests/win.c | 26 ++++++++++++++++++++++++++
 dlls/user32/win.c       |  6 ------
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index f0ea182..fef9cb0 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -6561,8 +6561,16 @@ static DWORD CALLBACK enablewindow_thread(LPVOID arg)
     return 0;
 }
 
+static LRESULT CALLBACK enable_window_procA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    if (msg == WM_CANCELMODE)
+        return 0;
+    return DefWindowProcA(hwnd, msg, wParam, lParam);
+}
+
 static void test_EnableWindow(void)
 {
+    WNDCLASSA cls;
     HWND hwnd;
     HANDLE hthread;
     DWORD tid;
@@ -6604,6 +6612,24 @@ static void test_EnableWindow(void)
 
     CloseHandle(hthread);
     DestroyWindow(hwnd);
+
+    /* test preventing release of capture */
+    memset(&cls, 0, sizeof(cls));
+    cls.lpfnWndProc = enable_window_procA;
+    cls.hInstance = GetModuleHandleA(0);
+    cls.lpszClassName = "EnableWindowClass";
+    ok(RegisterClassA(&cls), "RegisterClass failed\n");
+
+    hwnd = CreateWindowExA(0, "EnableWindowClass", NULL, WS_OVERLAPPEDWINDOW,
+                           0, 0, 100, 100, 0, 0, 0, NULL);
+    assert(hwnd);
+    SetFocus(hwnd);
+    SetCapture(hwnd);
+
+    EnableWindow(hwnd, FALSE);
+    check_wnd_state(hwnd, hwnd, 0, hwnd);
+
+    DestroyWindow(hwnd);
 }
 
 static DWORD CALLBACK gettext_msg_thread( LPVOID arg )
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index dd0bdb4..fb8f948 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2154,8 +2154,6 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
     }
     else if (!enable && !retvalue)
     {
-        HWND capture_wnd;
-
         SendMessageW( hwnd, WM_CANCELMODE, 0, 0);
 
         WIN_SetStyle( hwnd, WS_DISABLED, 0 );
@@ -2163,10 +2161,6 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
         if (hwnd == GetFocus())
             SetFocus( 0 );  /* A disabled window can't have the focus */
 
-        capture_wnd = GetCapture();
-        if (capture_wnd && (hwnd == capture_wnd || IsChild(hwnd, capture_wnd)))
-            ReleaseCapture();  /* A disabled window can't capture the mouse */
-
         SendMessageW( hwnd, WM_ENABLE, FALSE, 0 );
     }
     return retvalue;
-- 
2.7.4




More information about the wine-patches mailing list