From 516249001f76d10c6eeeff4c851047a404faf8e1 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 9 Mar 2022 15:19:47 +0100 Subject: [PATCH] win32u: Move NtUserFlashWindowEx implementation from user32. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/user32/driver.c | 12 +------ dlls/user32/user32.spec | 2 +- dlls/user32/user_main.c | 1 + dlls/user32/win.c | 60 +-------------------------------- dlls/win32u/driver.c | 6 ++++ dlls/win32u/gdiobj.c | 1 + dlls/win32u/message.c | 8 +++++ dlls/win32u/ntuser_private.h | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 4 +++ dlls/win32u/window.c | 64 ++++++++++++++++++++++++++++++++++++ dlls/win32u/wrappers.c | 6 ++++ include/ntuser.h | 1 + 13 files changed, 96 insertions(+), 72 deletions(-) diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 56b9cf8c484..c900373c5ef 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -156,10 +156,6 @@ static void CDECL nulldrv_DestroyWindow( HWND hwnd ) { } -static void CDECL nulldrv_FlashWindowEx( FLASHWINFO *info ) -{ -} - static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect, const RECT *top_rect, DWORD flags ) { @@ -267,11 +263,6 @@ static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd ) return load_driver()->pCreateWindow( hwnd ); } -static void CDECL loaderdrv_FlashWindowEx( FLASHWINFO *info ) -{ - load_driver()->pFlashWindowEx( info ); -} - static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect, const RECT *top_rect, DWORD flags ) { @@ -323,7 +314,7 @@ static struct user_driver_funcs lazy_load_driver = loaderdrv_CreateDesktopWindow, loaderdrv_CreateWindow, nulldrv_DestroyWindow, - loaderdrv_FlashWindowEx, + NULL, loaderdrv_GetDC, nulldrv_MsgWaitForMultipleObjectsEx, nulldrv_ReleaseDC, @@ -373,7 +364,6 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v SET_USER_FUNC(CreateDesktopWindow); SET_USER_FUNC(CreateWindow); SET_USER_FUNC(DestroyWindow); - SET_USER_FUNC(FlashWindowEx); SET_USER_FUNC(GetDC); SET_USER_FUNC(MsgWaitForMultipleObjectsEx); SET_USER_FUNC(ReleaseDC); diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 96b00593a70..4e3e2c40011 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -245,7 +245,7 @@ @ stdcall FindWindowExW(long long wstr wstr) @ stdcall FindWindowW(wstr wstr) @ stdcall FlashWindow(long long) -@ stdcall FlashWindowEx(ptr) +@ stdcall FlashWindowEx(ptr) NtUserFlashWindowEx @ stdcall FrameRect(long ptr long) @ stdcall FreeDDElParam(long long) @ stdcall GetActiveWindow() diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index f9fce07ddab..7e094d43e4d 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -140,6 +140,7 @@ static const struct user_callbacks user_funcs = GetWindowRect, RedrawWindow, SendMessageTimeoutW, + SendMessageW, WindowFromDC, free_dce, MSG_SendInternalMessageTimeout, diff --git a/dlls/user32/win.c b/dlls/user32/win.c index a5d1a640335..3f80995ea9c 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -3230,67 +3230,9 @@ BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert ) finfo.uCount = 1; finfo.dwTimeout = 0; finfo.hwnd = hWnd; - return FlashWindowEx( &finfo ); + return NtUserFlashWindowEx( &finfo ); } -/******************************************************************* - * FlashWindowEx (USER32.@) - */ -BOOL WINAPI FlashWindowEx( PFLASHWINFO pfinfo ) -{ - WND *wndPtr; - - TRACE( "%p\n", pfinfo ); - - if (!pfinfo) - { - SetLastError( ERROR_NOACCESS ); - return FALSE; - } - - if (!pfinfo->hwnd || pfinfo->cbSize != sizeof(FLASHWINFO) || !IsWindow( pfinfo->hwnd )) - { - SetLastError( ERROR_INVALID_PARAMETER ); - return FALSE; - } - FIXME( "%p - semi-stub\n", pfinfo ); - - if (IsIconic( pfinfo->hwnd )) - { - RedrawWindow( pfinfo->hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME ); - - wndPtr = WIN_GetPtr( pfinfo->hwnd ); - if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE; - if (pfinfo->dwFlags && !(wndPtr->flags & WIN_NCACTIVATED)) - { - wndPtr->flags |= WIN_NCACTIVATED; - } - else - { - wndPtr->flags &= ~WIN_NCACTIVATED; - } - WIN_ReleasePtr( wndPtr ); - USER_Driver->pFlashWindowEx( pfinfo ); - return TRUE; - } - else - { - WPARAM wparam; - HWND hwnd = pfinfo->hwnd; - - wndPtr = WIN_GetPtr( hwnd ); - if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE; - hwnd = wndPtr->obj.handle; /* make it a full handle */ - - if (pfinfo->dwFlags) wparam = !(wndPtr->flags & WIN_NCACTIVATED); - else wparam = (hwnd == NtUserGetForegroundWindow()); - - WIN_ReleasePtr( wndPtr ); - SendMessageW( hwnd, WM_NCACTIVATE, wparam, 0 ); - USER_Driver->pFlashWindowEx( pfinfo ); - return wparam; - } -} /******************************************************************* * GetWindowContextHelpId (USER32.@) diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 67a051f59f1..8e6263db60c 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -1032,6 +1032,11 @@ static void CDECL loaderdrv_UpdateDisplayDevices( const struct gdi_device_manage load_driver()->pUpdateDisplayDevices( manager, force, param ); } +static void CDECL loaderdrv_FlashWindowEx( FLASHWINFO *info ) +{ + load_driver()->pFlashWindowEx( info ); +} + static const struct vulkan_funcs * CDECL loaderdrv_wine_get_vulkan_driver( UINT version ) { return load_driver()->pwine_get_vulkan_driver( version ); @@ -1062,6 +1067,7 @@ static const struct user_driver_funcs lazy_load_driver = .pEnumDisplaySettingsEx = loaderdrv_EnumDisplaySettingsEx, .pUpdateDisplayDevices = loaderdrv_UpdateDisplayDevices, /* windowing functions */ + .pFlashWindowEx = loaderdrv_FlashWindowEx, .pMsgWaitForMultipleObjectsEx = nulldrv_MsgWaitForMultipleObjectsEx, .pScrollDC = nulldrv_ScrollDC, .pWindowMessage = nulldrv_WindowMessage, diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index 6dcb19b0ec3..38780d2accc 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1164,6 +1164,7 @@ static struct unix_funcs unix_funcs = NtUserEnumDisplayDevices, NtUserEnumDisplayMonitors, NtUserEnumDisplaySettings, + NtUserFlashWindowEx, NtUserGetAsyncKeyState, NtUserGetClassInfoEx, NtUserGetCursorInfo, diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 17648ebba45..d38647de8d8 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -101,3 +101,11 @@ BOOL WINAPI NtUserGetGUIThreadInfo( DWORD id, GUITHREADINFO *info ) SERVER_END_REQ; return ret; } + +/* see SendMessageW */ +LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + /* FIXME: move implementation from user32 */ + if (!user_callbacks) return 0; + return user_callbacks->pSendMessageW( hwnd, msg, wparam, lparam ); +} diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 4c05d070a0a..291a10f2abc 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -34,6 +34,7 @@ struct user_callbacks BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect ); 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 ); HWND (WINAPI *pWindowFromDC)( HDC ); void (WINAPI *free_dce)( struct dce *dce, HWND hwnd ); LRESULT (WINAPI *send_ll_message)( DWORD, DWORD, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR ); diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index dbc6d456e85..fdc4aa153b0 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -883,7 +883,7 @@ @ stub NtUserFillWindow @ stdcall -syscall NtUserFindExistingCursorIcon(ptr ptr ptr) @ stub NtUserFindWindowEx -@ stub NtUserFlashWindowEx +@ stdcall NtUserFlashWindowEx(ptr) @ stub NtUserForceWindowToDpiForTest @ stub NtUserFrostCrashedWindow @ stub NtUserFunctionalizeDisplayConfig diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index a46accddd71..d5d77897749 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -202,6 +202,7 @@ struct unix_funcs BOOL (WINAPI *pNtUserEnumDisplayMonitors)( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ); BOOL (WINAPI *pNtUserEnumDisplaySettings)( UNICODE_STRING *device, DWORD mode, DEVMODEW *dev_mode, DWORD flags ); + BOOL (WINAPI *pNtUserFlashWindowEx)( FLASHWINFO *info ); SHORT (WINAPI *pNtUserGetAsyncKeyState)( INT key ); ATOM (WINAPI *pNtUserGetClassInfoEx)( HINSTANCE instance, UNICODE_STRING *name, WNDCLASSEXW *wc, struct client_menu_name *menu_name, BOOL ansi ); @@ -277,6 +278,9 @@ extern LONG global_key_state_counter DECLSPEC_HIDDEN; extern BOOL get_cursor_pos( POINT *pt ) DECLSPEC_HIDDEN; extern DWORD get_input_state(void) DECLSPEC_HIDDEN; +/* message.c */ +extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN; + /* sysparams.c */ extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN; extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 7b5a6b3da03..1de2d5bc68c 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -676,6 +676,11 @@ static LONG_PTR get_win_data( const void *ptr, UINT size ) } } +static BOOL is_iconic( HWND hwnd ) +{ + return (get_window_long( hwnd, GWL_STYLE ) & WS_MINIMIZE) != 0; +} + static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ansi ) { LONG_PTR retval = 0; @@ -990,6 +995,65 @@ INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ) return lstrlenW(text); } +/******************************************************************* + * NtUserFlashWindowEx (win32u.@) + */ +BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info ) +{ + WND *win; + + TRACE( "%p\n", info ); + + if (!info) + { + SetLastError( ERROR_NOACCESS ); + return FALSE; + } + + if (!info->hwnd || info->cbSize != sizeof(FLASHWINFO) || !is_window( info->hwnd )) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return FALSE; + } + FIXME( "%p - semi-stub\n", info ); + + if (is_iconic( info->hwnd )) + { + user_callbacks->pRedrawWindow( info->hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME ); + + win = get_win_ptr( info->hwnd ); + if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE; + if (info->dwFlags && !(win->flags & WIN_NCACTIVATED)) + { + win->flags |= WIN_NCACTIVATED; + } + else + { + win->flags &= ~WIN_NCACTIVATED; + } + release_win_ptr( win ); + user_driver->pFlashWindowEx( info ); + return TRUE; + } + else + { + WPARAM wparam; + HWND hwnd = info->hwnd; + + win = get_win_ptr( hwnd ); + if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE; + hwnd = win->obj.handle; /* make it a full handle */ + + if (info->dwFlags) wparam = !(win->flags & WIN_NCACTIVATED); + else wparam = (hwnd == NtUserGetForegroundWindow()); + + release_win_ptr( win ); + send_message( hwnd, WM_NCACTIVATE, wparam, 0 ); + user_driver->pFlashWindowEx( info ); + return wparam; + } +} + /***************************************************************************** * NtUserCallHwnd (win32u.@) */ diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 642380480c6..02ec62e741b 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -789,6 +789,12 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode, return unix_funcs->pNtUserEnumDisplaySettings( device, mode, dev_mode, flags ); } +BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info ) +{ + if (!unix_funcs) return FALSE; + return unix_funcs->pNtUserFlashWindowEx( info ); +} + SHORT WINAPI NtUserGetAsyncKeyState( INT key ) { if (!unix_funcs) return 0; diff --git a/include/ntuser.h b/include/ntuser.h index 3fca830d5b2..b7d63f385ff 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -279,6 +279,7 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode, DEVMODEW *dev_mode, DWORD flags ); HICON WINAPI NtUserFindExistingCursorIcon( UNICODE_STRING *module, UNICODE_STRING *res_name, void *desc ); +BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info ); HWND WINAPI NtUserGetAncestor( HWND hwnd, UINT type ); SHORT WINAPI NtUserGetAsyncKeyState( INT key ); ULONG WINAPI NtUserGetAtomName( ATOM atom, UNICODE_STRING *name );