[PATCH 1/4] user32: Don't forward EnableWindow to the window's thread.

Zebediah Figura z.figura12 at gmail.com
Sun Mar 5 13:21:30 CST 2017


Fixes https://bugs.winehq.org/show_bug.cgi?id=42568

The only apparent use of this is to kill the focus and capture of
the window if the thread doesn't own it. However, testing reveals
that on Windows the focus isn't killed either, and the capture is
handled by DefWindowProc, as already implemented in Wine.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/user32/message.c      |  3 ---
 dlls/user32/spy.c          |  1 -
 dlls/user32/tests/msg.c    |  8 +++-----
 dlls/user32/user_private.h |  1 -
 dlls/user32/win.c          | 12 ------------
 5 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 9bfb453..058b34f 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -1867,9 +1867,6 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
         return (LRESULT)SetParent( hwnd, (HWND)wparam );
     case WM_WINE_SETWINDOWLONG:
         return WIN_SetWindowLong( hwnd, (short)LOWORD(wparam), HIWORD(wparam), lparam, TRUE );
-    case WM_WINE_ENABLEWINDOW:
-        if (is_desktop_window( hwnd )) return 0;
-        return EnableWindow( hwnd, wparam );
     case WM_WINE_SETACTIVEWINDOW:
         if (is_desktop_window( hwnd )) return 0;
         if (!wparam && GetForegroundWindow() == hwnd) return 0;
diff --git a/dlls/user32/spy.c b/dlls/user32/spy.c
index 4f8e56f..1e177bd 100644
--- a/dlls/user32/spy.c
+++ b/dlls/user32/spy.c
@@ -1136,7 +1136,6 @@ static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
     "WM_WINE_SHOWWINDOW",
     "WM_WINE_SETPARENT",
     "WM_WINE_SETWINDOWLONG",
-    "WM_WINE_ENABLEWINDOW",
     "WM_WINE_SETACTIVEWINDOW",
     "WM_WINE_KEYBOARD_LL_HOOK",
     "WM_WINE_MOUSE_LL_HOOK",
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 19a1f31..a682b70 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -16332,7 +16332,7 @@ static void test_SendMessage_other_thread(int thread_n)
     GetMessageA(&msg, 0, 0, 0);
     ok(msg.message == WM_USER, "expected WM_USER, got %04x\n", msg.message);
     DispatchMessageA(&msg);
-    ok_sequence(send_message_1, "SendMessage from other thread 1", thread_n == 2);
+    ok_sequence(send_message_1, "SendMessage from other thread 1", FALSE);
 
     /* intentionally yield */
     MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input);
@@ -16347,7 +16347,7 @@ static void test_SendMessage_other_thread(int thread_n)
     trace("main: call PeekMessage\n");
     ok(PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "PeekMessage should not fail\n");
     ok(msg.message == WM_USER+1, "expected WM_USER+1, got %04x\n", msg.message);
-    ok_sequence(send_message_3, "SendMessage from other thread 3", thread_n == 2);
+    ok_sequence(send_message_3, "SendMessage from other thread 3", FALSE);
 
     trace("main: call PeekMessage\n");
     ok(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should not fail\n");
@@ -16359,13 +16359,11 @@ static void test_SendMessage_other_thread(int thread_n)
     MsgWaitForMultipleObjects(0, NULL, FALSE, 100, qs_all_input);
 
     ret = GetQueueStatus(QS_SENDMESSAGE|QS_POSTMESSAGE);
-    /* FIXME: remove once Wine is fixed */
-todo_wine_if (thread_n == 2)
     ok(ret == 0, "wrong status %08x\n", ret);
 
     trace("main: call PeekMessage\n");
     ok(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE), "PeekMessage should fail\n");
-    ok_sequence(WmEmptySeq, "SendMessage from other thread 5", thread_n == 2);
+    ok_sequence(WmEmptySeq, "SendMessage from other thread 5", FALSE);
 
     ret = GetQueueStatus(QS_SENDMESSAGE|QS_POSTMESSAGE);
     ok(ret == 0, "wrong status %08x\n", ret);
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 0b5b2ac..e5fb263 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -48,7 +48,6 @@ enum wine_internal_message
     WM_WINE_SHOWWINDOW,
     WM_WINE_SETPARENT,
     WM_WINE_SETWINDOWLONG,
-    WM_WINE_ENABLEWINDOW,
     WM_WINE_SETACTIVEWINDOW,
     WM_WINE_KEYBOARD_LL_HOOK,
     WM_WINE_MOUSE_LL_HOOK,
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 4406577..74b4fa2 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2137,7 +2137,6 @@ HWND WINAPI GetDesktopWindow(void)
 BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
 {
     BOOL retvalue;
-    HWND full_handle;
 
     if (is_broadcast(hwnd))
     {
@@ -2145,11 +2144,6 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
         return FALSE;
     }
 
-    if (!(full_handle = WIN_IsCurrentThread( hwnd )))
-        return SendMessageW( hwnd, WM_WINE_ENABLEWINDOW, enable, 0 );
-
-    hwnd = full_handle;
-
     TRACE("( %p, %d )\n", hwnd, enable);
 
     retvalue = !IsWindowEnabled( hwnd );
@@ -2161,8 +2155,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 );
@@ -2170,10 +2162,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 (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