From 033cad432e1d93a0ddf5a5b71a989f31441f588c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 15 Apr 2022 20:43:19 +0200 Subject: [PATCH] win32u: Copy implementation of AdjustWindowRectEx from user32. It will be useful for drivers as well. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/user32/user_main.c | 1 - dlls/win32u/defwnd.c | 38 ++++++++++++++++++++++++++++++++++++ dlls/win32u/ntuser_private.h | 1 - dlls/win32u/window.c | 4 +--- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index fa849e9cf2d..b282056d8c8 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -159,7 +159,6 @@ static void CDECL free_win_ptr( WND *win ) static const struct user_callbacks user_funcs = { - AdjustWindowRectEx, CopyImage, EndMenu, ImmProcessKey, diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index 0080d4f7cc6..7455a91980c 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -31,6 +31,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(win); +/*********************************************************************** + * AdjustWindowRectEx (win32u.so) + */ +BOOL WINAPI AdjustWindowRectEx( RECT *rect, DWORD style, BOOL menu, DWORD ex_style ) +{ + NONCLIENTMETRICSW ncm; + int adjust = 0; + + ncm.cbSize = sizeof(ncm); + NtUserSystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + + if ((ex_style & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) + adjust = 1; /* for the outer frame always present */ + else if ((ex_style & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME))) + adjust = 2; /* outer */ + + if (style & WS_THICKFRAME) + adjust += ncm.iBorderWidth + ncm.iPaddedBorderWidth; /* The resize border */ + + if ((style & (WS_BORDER|WS_DLGFRAME)) || (ex_style & WS_EX_DLGMODALFRAME)) + adjust++; /* The other border */ + + InflateRect( rect, adjust, adjust ); + + if ((style & WS_CAPTION) == WS_CAPTION) + { + if (ex_style & WS_EX_TOOLWINDOW) + rect->top -= ncm.iSmCaptionHeight + 1; + else + rect->top -= ncm.iCaptionHeight + 1; + } + if (menu) rect->top -= ncm.iMenuHeight + 1; + + if (ex_style & WS_EX_CLIENTEDGE) + InflateRect( rect, get_system_metrics(SM_CXEDGE), get_system_metrics(SM_CYEDGE) ); + return TRUE; +} + static BOOL set_window_text( HWND hwnd, const void *text, BOOL ansi ) { static const WCHAR emptyW[] = { 0 }; diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index c870037f7b3..6e25e0ec0db 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -32,7 +32,6 @@ struct hardware_msg_data; struct user_callbacks { - BOOL (WINAPI *pAdjustWindowRectEx)( RECT *, DWORD, BOOL, DWORD ); HANDLE (WINAPI *pCopyImage)( HANDLE, UINT, INT, INT, UINT ); BOOL (WINAPI *pEndMenu)(void); BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index edafc522d14..9231f98539e 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -3683,9 +3683,7 @@ static MINMAXINFO get_min_max_info( HWND hwnd ) adjusted_style = style; get_client_rect( NtUserGetAncestor( hwnd, GA_PARENT ), &rc ); - if (user_callbacks) - user_callbacks->pAdjustWindowRectEx( &rc, adjusted_style, - (style & WS_POPUP) && get_menu( hwnd ), exstyle); + AdjustWindowRectEx( &rc, adjusted_style, (style & WS_POPUP) && get_menu( hwnd ), exstyle ); xinc = -rc.left; yinc = -rc.top;