Module: wine Branch: master Commit: b5ddd14448d2a780ccab7bb672e66fbfd3ec7b4f URL: https://source.winehq.org/git/wine.git/?a=commit;h=b5ddd14448d2a780ccab7bb67...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Mar 10 14:32:56 2022 +0100
win32u: Move WM_WINE_UPDATEWINDOWSTATE implementation from user32.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/message.c | 3 --- dlls/user32/user_main.c | 2 ++ dlls/user32/user_private.h | 1 - dlls/user32/win.c | 2 +- dlls/win32u/message.c | 11 +++++++++++ dlls/win32u/ntuser_private.h | 4 ++++ dlls/win32u/sysparams.c | 42 ++++++++++++++++++++++++++++++++++++++++++ dlls/win32u/win32u_private.h | 3 +++ dlls/win32u/window.c | 26 ++++++++++++++++++++++++++ 9 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 85b3b672cfc..577120032bf 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -1878,9 +1878,6 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar case WM_WINE_SETACTIVEWINDOW: if (!wparam && NtUserGetForegroundWindow() == hwnd) return 0; return (LRESULT)SetActiveWindow( (HWND)wparam ); - case WM_WINE_UPDATEWINDOWSTATE: - update_window_state( hwnd ); - return 0; default: { MSG m; diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 4103d3dc7a8..ef8b35128b4 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -136,6 +136,7 @@ static void dpiaware_init(void) static const struct user_callbacks user_funcs = { CopyImage, + PostMessageW, RedrawWindow, SendMessageTimeoutW, SendMessageW, @@ -146,6 +147,7 @@ static const struct user_callbacks user_funcs = register_builtin_classes, MSG_SendInternalMessageTimeout, (void *)__wine_set_user_driver, + set_window_pos, };
static void WINAPI User32CallFreeIcon( ULONG *param, ULONG size ) diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index e2e371e32c0..453eb58c30d 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -124,7 +124,6 @@ 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 wait_graphics_driver_ready(void) 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; diff --git a/dlls/user32/win.c b/dlls/user32/win.c index bb792037640..885c06c90ca 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -308,7 +308,7 @@ static void send_parent_notify( HWND hwnd, UINT msg ) * * Trigger an update of the window's driver state and surface. */ -void update_window_state( HWND hwnd ) +static void update_window_state( HWND hwnd ) { DPI_AWARENESS_CONTEXT context; RECT window_rect, client_rect, valid_rects[2]; diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index abfbd7d9c69..b995ee60a0e 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -56,6 +56,9 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM 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 ); @@ -118,3 +121,11 @@ LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) if (!user_callbacks) return 0; return user_callbacks->pSendMessageW( hwnd, msg, wparam, lparam ); } + +/* see PostMessageW */ +LRESULT post_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + /* FIXME: move implementation from user32 */ + if (!user_callbacks) return 0; + return user_callbacks->pPostMessageW( hwnd, msg, wparam, lparam ); +} diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 654429b994b..52be42f61ea 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -30,6 +30,7 @@ struct dce; struct user_callbacks { HANDLE (WINAPI *pCopyImage)( HANDLE, UINT, INT, INT, UINT ); + BOOL (WINAPI *pPostMessageW)( HWND, UINT, WPARAM, LPARAM ); BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT ); LRESULT (WINAPI *pSendMessageTimeoutW)( HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR ); LRESULT (WINAPI *pSendMessageW)( HWND, UINT, WPARAM, LPARAM ); @@ -40,6 +41,9 @@ struct user_callbacks void (CDECL *register_builtin_classes)(void); LRESULT (WINAPI *send_ll_message)( DWORD, DWORD, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR ); void (CDECL *set_user_driver)( void *, UINT ); + BOOL (CDECL *set_window_pos)( HWND hwnd, HWND insert_after, UINT swp_flags, + const RECT *window_rect, const RECT *client_rect, + const RECT *valid_rects ); };
struct user_object diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 39f8cf53345..a342d35a947 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1436,6 +1436,48 @@ UINT get_system_dpi(void) return system_dpi; }
+/* see GetAwarenessFromDpiAwarenessContext */ +static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) +{ + switch ((ULONG_PTR)context) + { + case 0x10: + case 0x11: + case 0x12: + case 0x80000010: + case 0x80000011: + case 0x80000012: + return (ULONG_PTR)context & 3; + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: + return ~(ULONG_PTR)context; + default: + return DPI_AWARENESS_INVALID; + } +} + +/* see SetThreadDpiAwarenessContext */ +DPI_AWARENESS_CONTEXT set_thread_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) +{ + struct user_thread_info *info = get_user_thread_info(); + DPI_AWARENESS prev, val = get_awareness_from_dpi_awareness_context( context ); + + if (val == DPI_AWARENESS_INVALID) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return 0; + } + if (!(prev = info->dpi_awareness)) + { + prev = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ) & 3; + prev |= 0x80000010; /* restore to process default */ + } + if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0; + else info->dpi_awareness = val | 0x10; + return ULongToHandle( prev ); +} + /********************************************************************** * map_dpi_rect */ diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 6bdad368f70..f1e59055e02 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -284,6 +284,7 @@ extern BOOL get_cursor_pos( POINT *pt ) DECLSPEC_HIDDEN; extern DWORD get_input_state(void) DECLSPEC_HIDDEN;
/* message.c */ +extern LRESULT post_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
/* sysparams.c */ @@ -301,6 +302,7 @@ extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDE extern HMONITOR monitor_from_point( POINT pt, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; extern HMONITOR monitor_from_rect( const RECT *rect, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; extern HMONITOR monitor_from_window( HWND hwnd, DWORD flags, UINT dpi ) DECLSPEC_HIDDEN; +extern DPI_AWARENESS_CONTEXT set_thread_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) DECLSPEC_HIDDEN; extern void user_lock(void) DECLSPEC_HIDDEN; extern void user_unlock(void) DECLSPEC_HIDDEN; extern void user_check_not_lock(void) DECLSPEC_HIDDEN; @@ -316,6 +318,7 @@ extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; extern BOOL get_window_rect( HWND hwnd, RECT *rect, UINT dpi ) DECLSPEC_HIDDEN; extern void register_window_surface( struct window_surface *old, struct window_surface *new ) DECLSPEC_HIDDEN; +extern void update_window_state( HWND hwnd ) DECLSPEC_HIDDEN;
/* to release pointers retrieved by win_get_ptr */ static inline void release_win_ptr( struct tagWND *ptr ) diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 1e80c5d39f8..35953143f37 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1642,6 +1642,32 @@ INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ) return lstrlenW(text); }
+/******************************************************************* + * update_window_state + * + * Trigger an update of the window's driver state and surface. + */ +void update_window_state( HWND hwnd ) +{ + DPI_AWARENESS_CONTEXT context; + RECT window_rect, client_rect, valid_rects[2]; + + if (!is_current_thread_window( hwnd )) + { + post_message( hwnd, WM_WINE_UPDATEWINDOWSTATE, 0, 0 ); + return; + } + + context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( hwnd )); + get_window_rects( hwnd, COORDS_PARENT, &window_rect, &client_rect, get_thread_dpi() ); + valid_rects[0] = valid_rects[1] = client_rect; + if (user_callbacks) + user_callbacks->set_window_pos( hwnd, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | + SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW, + &window_rect, &client_rect, valid_rects ); + set_thread_dpi_awareness_context( context ); +} + /******************************************************************* * NtUserFlashWindowEx (win32u.@) */