Module: wine Branch: master Commit: 77013e97960e10a7e0ea4dd7e239dc0668d54f48 URL: https://source.winehq.org/git/wine.git/?a=commit;h=77013e97960e10a7e0ea4dd7e...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Apr 17 11:22:52 2018 +0200
user32: Reimplement AdjustWindowRectEx using NONCLIENTMETRICSW.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/nonclient.c | 100 +++++++++--------------------------------------- dlls/user32/tests/win.c | 32 +++++++--------- 2 files changed, 33 insertions(+), 99 deletions(-)
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c index 3f3d96a..1bdb823 100644 --- a/dlls/user32/nonclient.c +++ b/dlls/user32/nonclient.c @@ -55,54 +55,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(nonclient); (((exStyle) & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == \ WS_EX_STATICEDGE)
-#define HAS_ANYFRAME(style,exStyle) \ - (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \ - ((exStyle) & WS_EX_DLGMODALFRAME) || \ - !((style) & (WS_CHILD | WS_POPUP))) - #define HAS_MENU(hwnd,style) ((((style) & (WS_CHILD | WS_POPUP)) != WS_CHILD) && GetMenu(hwnd))
-/****************************************************************************** - * NC_AdjustRectOuter - * - * Computes the size of the "outside" parts of the window based on the - * parameters of the client area. - * - * PARAMS - * LPRECT rect - * DWORD style - * BOOL menu - * DWORD exStyle - * - * NOTES - * "Outer" parts of a window means the whole window frame, caption and - * menu bar. It does not include "inner" parts of the frame like client - * edge, static edge or scroll bars. - * - *****************************************************************************/ - -static void -NC_AdjustRectOuter (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle) +static void adjust_window_rect( RECT *rect, DWORD style, BOOL menu, DWORD exStyle, NONCLIENTMETRICSW *ncm ) { - int adjust; + int adjust = 0;
- if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == - WS_EX_STATICEDGE) - { + if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) adjust = 1; /* for the outer frame always present */ - } - else - { - adjust = 0; - if ((exStyle & WS_EX_DLGMODALFRAME) || - (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */ - } + else if ((exStyle & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME))) + adjust = 2; /* outer */ + if (style & WS_THICKFRAME) - adjust += ( GetSystemMetrics (SM_CXFRAME) - - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */ - if ((style & (WS_BORDER|WS_DLGFRAME)) || - (exStyle & WS_EX_DLGMODALFRAME)) + adjust += ncm->iBorderWidth + ncm->iPaddedBorderWidth; /* The resize border */ + + if ((style & (WS_BORDER|WS_DLGFRAME)) || (exStyle & WS_EX_DLGMODALFRAME)) adjust++; /* The other border */
InflateRect (rect, adjust, adjust); @@ -110,50 +78,17 @@ NC_AdjustRectOuter (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle) if ((style & WS_CAPTION) == WS_CAPTION) { if (exStyle & WS_EX_TOOLWINDOW) - rect->top -= GetSystemMetrics(SM_CYSMCAPTION); + rect->top -= ncm->iSmCaptionHeight + 1; else - rect->top -= GetSystemMetrics(SM_CYCAPTION); + rect->top -= ncm->iCaptionHeight + 1; } - if (menu) rect->top -= GetSystemMetrics(SM_CYMENU); -} + if (menu) rect->top -= ncm->iMenuHeight + 1;
- -/****************************************************************************** - * NC_AdjustRectInner - * - * Computes the size of the "inside" part of the window based on the - * parameters of the client area. - * - * PARAMS - * LPRECT rect - * DWORD style - * DWORD exStyle - * - * NOTES - * "Inner" part of a window means the window frame inside of the flat - * window frame. It includes the client edge, the static edge and the - * scroll bars. - * - *****************************************************************************/ - -static void -NC_AdjustRectInner (LPRECT rect, DWORD style, DWORD exStyle) -{ if (exStyle & WS_EX_CLIENTEDGE) InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); - - if (style & WS_VSCROLL) - { - if((exStyle & WS_EX_LEFTSCROLLBAR) != 0) - rect->left -= GetSystemMetrics(SM_CXVSCROLL); - else - rect->right += GetSystemMetrics(SM_CXVSCROLL); - } - if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL); }
- static HICON NC_IconForWindow( HWND hwnd ) { HICON hIcon = 0; @@ -378,13 +313,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRect( LPRECT rect, DWORD style, BOOL m */ BOOL WINAPI DECLSPEC_HOTPATCH AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) { + NONCLIENTMETRICSW ncm; + if (style & WS_MINIMIZE) return TRUE; - style &= ~(WS_HSCROLL | WS_VSCROLL);
TRACE("(%s) %08x %d %08x\n", wine_dbgstr_rect(rect), style, menu, exStyle );
- NC_AdjustRectOuter( rect, style, menu, exStyle ); - NC_AdjustRectInner( rect, style, exStyle ); + ncm.cbSize = sizeof(ncm); + SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + + adjust_window_rect( rect, style, menu, exStyle, &ncm );
return TRUE; } @@ -411,7 +349,7 @@ LRESULT NC_HandleNCCalcSize( HWND hwnd, WPARAM wparam, RECT *winRect )
if (!(style & WS_MINIMIZE)) { - NC_AdjustRectOuter( &tmpRect, style, FALSE, exStyle ); + AdjustWindowRectEx( &tmpRect, style, FALSE, exStyle & ~WS_EX_CLIENTEDGE);
winRect->left -= tmpRect.left; winRect->top -= tmpRect.top; diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index e8d0b0f..61bb736 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -1014,23 +1014,19 @@ static void FixedAdjustWindowRectEx(RECT* rc, LONG style, BOOL menu, LONG exstyl /* reimplement it to check that the Wine algorithm gives the correct result */ static void wine_AdjustWindowRectEx( RECT *rect, LONG style, BOOL menu, LONG exStyle ) { - int adjust; + NONCLIENTMETRICSW ncm; + int adjust = 0;
- if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == - WS_EX_STATICEDGE) - { + ncm.cbSize = offsetof( NONCLIENTMETRICSW, iPaddedBorderWidth ); + SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); + + if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) == WS_EX_STATICEDGE) adjust = 1; /* for the outer frame always present */ - } - else - { - adjust = 0; - if ((exStyle & WS_EX_DLGMODALFRAME) || - (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */ - } - if (style & WS_THICKFRAME) - adjust += GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME); /* The resize border */ - if ((style & (WS_BORDER|WS_DLGFRAME)) || - (exStyle & WS_EX_DLGMODALFRAME)) + else if ((exStyle & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME))) + adjust = 2; /* outer */ + + if (style & WS_THICKFRAME) adjust += ncm.iBorderWidth; /* The resize border */ + if ((style & (WS_BORDER|WS_DLGFRAME)) || (exStyle & WS_EX_DLGMODALFRAME)) adjust++; /* The other border */
InflateRect (rect, adjust, adjust); @@ -1038,11 +1034,11 @@ static void wine_AdjustWindowRectEx( RECT *rect, LONG style, BOOL menu, LONG exS if ((style & WS_CAPTION) == WS_CAPTION) { if (exStyle & WS_EX_TOOLWINDOW) - rect->top -= GetSystemMetrics(SM_CYSMCAPTION); + rect->top -= ncm.iSmCaptionHeight + 1; else - rect->top -= GetSystemMetrics(SM_CYCAPTION); + rect->top -= ncm.iCaptionHeight + 1; } - if (menu) rect->top -= GetSystemMetrics(SM_CYMENU); + if (menu) rect->top -= ncm.iMenuHeight + 1;
if (exStyle & WS_EX_CLIENTEDGE) InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));