Matteo Bruni : user32: Make sure update_window_state() is always executed on the owner thread.

Alexandre Julliard julliard at winehq.org
Fri Jun 5 14:16:52 CDT 2020


Module: wine
Branch: master
Commit: f0e9cf11450e569b86174314f39dc687d41278c4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f0e9cf11450e569b86174314f39dc687d41278c4

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Fri Jun  5 11:47:30 2020 +0200

user32: Make sure update_window_state() is always executed on the owner thread.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/message.c      | 3 +++
 dlls/user32/spy.c          | 3 ++-
 dlls/user32/user_private.h | 2 ++
 dlls/user32/win.c          | 8 +++++++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 2717d91dbb..45fc07bbff 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -1890,6 +1890,9 @@ static LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPAR
             return USER_Driver->pClipCursor( &rect );
         }
         return USER_Driver->pClipCursor( NULL );
+    case WM_WINE_UPDATEWINDOWSTATE:
+        update_window_state( hwnd );
+        return 0;
     default:
         if (msg >= WM_WINE_FIRST_DRIVER_MSG && msg <= WM_WINE_LAST_DRIVER_MSG)
             return USER_Driver->pWindowMessage( hwnd, msg, wparam, lparam );
diff --git a/dlls/user32/spy.c b/dlls/user32/spy.c
index 8a2fa430b5..dea97547b3 100644
--- a/dlls/user32/spy.c
+++ b/dlls/user32/spy.c
@@ -1150,7 +1150,7 @@ static const char * const CCMMessageTypeNames[SPY_MAX_CCMMSGNUM + 1] =
     "CCM_SETNOTIFYWINDOW"
 };
 
-#define SPY_MAX_WINEMSGNUM   (WM_WINE_CLIPCURSOR - WM_WINE_DESTROYWINDOW)
+#define SPY_MAX_WINEMSGNUM   (WM_WINE_UPDATEWINDOWSTATE - WM_WINE_DESTROYWINDOW)
 static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
 {
     "WM_WINE_DESTROYWINDOW",
@@ -1163,6 +1163,7 @@ static const char * const WINEMessageTypeNames[SPY_MAX_WINEMSGNUM + 1] =
     "WM_WINE_KEYBOARD_LL_HOOK",
     "WM_WINE_MOUSE_LL_HOOK",
     "WM_WINE_CLIPCURSOR",
+    "WM_WINE_UPDATEWINDOWSTATE",
 };
 
 /* Virtual key names */
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 7e294558ef..0230dd4500 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -56,6 +56,7 @@ enum wine_internal_message
     WM_WINE_KEYBOARD_LL_HOOK,
     WM_WINE_MOUSE_LL_HOOK,
     WM_WINE_CLIPCURSOR,
+    WM_WINE_UPDATEWINDOWSTATE,
     WM_WINE_FIRST_DRIVER_MSG = 0x80001000,  /* range of messages reserved for the USER driver */
     WM_WINE_LAST_DRIVER_MSG = 0x80001fff
 };
@@ -243,6 +244,7 @@ extern void move_window_bits( HWND hwnd, struct window_surface *old_surface,
                               const RECT *window_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN;
 extern void move_window_bits_parent( HWND hwnd, HWND parent, const RECT *window_rect,
                                      const RECT *valid_rects ) DECLSPEC_HIDDEN;
+extern void update_window_state( HWND hwnd ) DECLSPEC_HIDDEN;
 extern void *get_hook_proc( void *proc, const WCHAR *module, HMODULE *free_module ) DECLSPEC_HIDDEN;
 extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 3323ed3e41..49cebe9979 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -445,11 +445,17 @@ static void send_parent_notify( HWND hwnd, UINT msg )
  *
  * Trigger an update of the window's driver state and surface.
  */
-static void update_window_state( HWND hwnd )
+void update_window_state( HWND hwnd )
 {
     DPI_AWARENESS_CONTEXT context;
     RECT window_rect, client_rect, valid_rects[2];
 
+    if (!WIN_IsCurrentThread( hwnd ))
+    {
+        PostMessageW( hwnd, WM_WINE_UPDATEWINDOWSTATE, 0, 0 );
+        return;
+    }
+
     context = SetThreadDpiAwarenessContext( GetWindowDpiAwarenessContext( hwnd ));
     WIN_GetRectangles( hwnd, COORDS_PARENT, &window_rect, &client_rect );
     valid_rects[0] = valid_rects[1] = client_rect;




More information about the wine-cvs mailing list