[PATCH v3 1/6] user32: Move internal message from EnableWindow() to WIN_SetStyle().

Zebediah Figura z.figura12 at gmail.com
Sun Mar 26 17:41:31 CDT 2017


This is the only part that needs internal messaging, and, in fact,
should be preferred, since otherwise the focus is incorrectly killed.
The capture is already killed by handling WM_CANCELMODE, as in Windows.

This causes the internal message tests to be "fixed", however, the
underlying phenomenon still exists, so I have changed the function to
SetParent(), which still displays the relevant behaviour.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/user32/message.c      |  4 ++--
 dlls/user32/spy.c          |  2 +-
 dlls/user32/tests/msg.c    |  4 ++--
 dlls/user32/user_private.h |  2 +-
 dlls/user32/win.c          | 15 +--------------
 5 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 9bfb453..d13a9b0 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -1867,9 +1867,9 @@ 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:
+    case WM_WINE_SETSTYLE:
         if (is_desktop_window( hwnd )) return 0;
-        return EnableWindow( hwnd, wparam );
+        return WIN_SetStyle(hwnd, wparam, lparam);
     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..ff80051 100644
--- a/dlls/user32/spy.c
+++ b/dlls/user32/spy.c
@@ -1136,7 +1136,7 @@ static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
     "WM_WINE_SHOWWINDOW",
     "WM_WINE_SETPARENT",
     "WM_WINE_SETWINDOWLONG",
-    "WM_WINE_ENABLEWINDOW",
+    "WM_WINE_SETSTYLE",
     "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..7bdb65a 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -16279,8 +16279,8 @@ static DWORD WINAPI SendMessage_thread_2(void *param)
     PostMessageA(wnd_event->hwnd, WM_USER+1, 0, 0);
 
     /* this leads to sending an internal message under Wine */
-    trace("thread: call EnableWindow\n");
-    EnableWindow(wnd_event->hwnd, TRUE);
+    trace("thread: call SetParent\n");
+    SetParent(wnd_event->hwnd, wnd_event->hwnd);
 
     trace("thread: call SendMessage\n");
     SendMessageA(wnd_event->hwnd, WM_USER+2, 0, 0);
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 0b5b2ac..b4a756c 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -48,7 +48,7 @@ enum wine_internal_message
     WM_WINE_SHOWWINDOW,
     WM_WINE_SETPARENT,
     WM_WINE_SETWINDOWLONG,
-    WM_WINE_ENABLEWINDOW,
+    WM_WINE_SETSTYLE,
     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 f3b4ef5..fb8f948 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -768,8 +768,7 @@ ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits )
     if (win == WND_OTHER_PROCESS)
     {
         if (IsWindow(hwnd))
-            ERR( "cannot set style %x/%x on other process window %p\n",
-                 set_bits, clear_bits, hwnd );
+            return SendMessageW(hwnd, WM_WINE_SETSTYLE, set_bits, clear_bits);
         return 0;
     }
     style.styleOld = win->dwStyle;
@@ -2137,7 +2136,6 @@ HWND WINAPI GetDesktopWindow(void)
 BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
 {
     BOOL retvalue;
-    HWND full_handle;
 
     if (is_broadcast(hwnd))
     {
@@ -2145,11 +2143,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 +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 );
@@ -2170,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