Alexandre Julliard : user32: Fix WS_EX_DLGMODALFRAME handling in AdjustWindowRect and add more tests.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Dec 7 08:26:42 CST 2015
Module: wine
Branch: master
Commit: 5095ee32af3b997e98989c8c1e622d84a76db6c3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5095ee32af3b997e98989c8c1e622d84a76db6c3
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Dec 7 21:20:39 2015 +0900
user32: Fix WS_EX_DLGMODALFRAME handling in AdjustWindowRect and add more tests.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comdlg32/tests/filedlg.c | 2 +-
dlls/user32/nonclient.c | 2 +-
dlls/user32/tests/win.c | 106 +++++++++++++++++++++++++++++++++++-------
3 files changed, 91 insertions(+), 19 deletions(-)
diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c
index 49a430c..0a4c509 100644
--- a/dlls/comdlg32/tests/filedlg.c
+++ b/dlls/comdlg32/tests/filedlg.c
@@ -781,7 +781,7 @@ static UINT_PTR WINAPI template_hook_arrange(HWND dlgChild, UINT msg, WPARAM wPa
ok( wrcParent.right - wrcParent.left == expectx,
"Wrong width of dialog %d, expected %d\n",
wrcParent.right - wrcParent.left, expectx);
- } else todo_wine {
+ } else {
/* with the OFN_ENABLESIZING flag */
ok( wrcParent.bottom - wrcParent.top > expecty,
"Wrong height of dialog %d, expected more than %d\n",
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index 1267ab6..053353a 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -98,7 +98,7 @@ NC_AdjustRectOuter (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
if ((exStyle & WS_EX_DLGMODALFRAME) ||
(style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
}
- if ((style & WS_THICKFRAME) && !(exStyle & WS_EX_DLGMODALFRAME))
+ if (style & WS_THICKFRAME)
adjust += ( GetSystemMetrics (SM_CXFRAME)
- GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */
if ((style & (WS_BORDER|WS_DLGFRAME)) ||
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 30b3da9..b202544 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -989,6 +989,52 @@ static void FixedAdjustWindowRectEx(RECT* rc, LONG style, BOOL menu, LONG exstyl
rc->bottom += GetSystemMetrics(SM_CYHSCROLL);
}
+/* 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;
+
+ 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))
+ adjust++; /* The other border */
+
+ InflateRect (rect, adjust, adjust);
+
+ if ((style & WS_CAPTION) == WS_CAPTION)
+ {
+ if (exStyle & WS_EX_TOOLWINDOW)
+ rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
+ else
+ rect->top -= GetSystemMetrics(SM_CYCAPTION);
+ }
+ if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
+
+ 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 void test_nonclient_area(HWND hwnd)
{
DWORD style, exstyle;
@@ -1016,6 +1062,14 @@ static void test_nonclient_area(HWND hwnd)
style, exstyle, menu, rc_window.left, rc_window.top, rc_window.right, rc_window.bottom,
rc.left, rc.top, rc.right, rc.bottom);
+ CopyRect(&rc, &rc_client);
+ MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
+ wine_AdjustWindowRectEx(&rc, style, menu, exstyle);
+ ok(EqualRect(&rc, &rc_window),
+ "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
+ style, exstyle, menu, rc_window.left, rc_window.top, rc_window.right, rc_window.bottom,
+ rc.left, rc.top, rc.right, rc.bottom);
+
CopyRect(&rc, &rc_window);
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc);
@@ -4747,26 +4801,16 @@ static BOOL AWR_init(void)
static void test_AWR_window_size(BOOL menu)
{
- LONG styles[] = {
- WS_POPUP,
- WS_MAXIMIZE, WS_BORDER, WS_DLGFRAME,
- WS_SYSMENU,
- WS_THICKFRAME,
- WS_MINIMIZEBOX, WS_MAXIMIZEBOX,
- WS_HSCROLL, WS_VSCROLL
+ static const DWORD styles[] = {
+ WS_POPUP, WS_MAXIMIZE, WS_BORDER, WS_DLGFRAME, WS_CAPTION, WS_SYSMENU,
+ WS_THICKFRAME, WS_MINIMIZEBOX, WS_MAXIMIZEBOX, WS_HSCROLL, WS_VSCROLL
};
- LONG exStyles[] = {
- WS_EX_CLIENTEDGE,
- WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE,
- WS_EX_APPWINDOW,
-#if 0
- /* These styles have problems on (at least) WinXP (SP2) and Wine */
- WS_EX_DLGMODALFRAME,
- WS_EX_STATICEDGE,
-#endif
+ static const DWORD exStyles[] = {
+ WS_EX_CLIENTEDGE, WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE, WS_EX_APPWINDOW,
+ WS_EX_DLGMODALFRAME, WS_EX_DLGMODALFRAME | WS_EX_STATICEDGE
};
- int i;
+ unsigned int i;
/* A exhaustive check of all the styles takes too long
* so just do a (hopefully representative) sample
@@ -4778,6 +4822,33 @@ static void test_AWR_window_size(BOOL menu)
test_AWRwindow(szAWRClass, WS_THICKFRAME, exStyles[i], menu);
}
}
+
+static void test_AWR_flags(void)
+{
+ static const DWORD styles[] = { WS_POPUP, WS_BORDER, WS_DLGFRAME, WS_THICKFRAME };
+ static const DWORD exStyles[] = { WS_EX_CLIENTEDGE, WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE,
+ WS_EX_APPWINDOW, WS_EX_DLGMODALFRAME, WS_EX_STATICEDGE };
+
+ DWORD i, j, k, style, exstyle;
+ RECT rect, rect2;
+
+ for (i = 0; i < (1 << COUNTOF(styles)); i++)
+ {
+ for (k = style = 0; k < COUNTOF(styles); k++) if (i & (1 << k)) style |= styles[k];
+
+ for (j = 0; j < (1 << COUNTOF(exStyles)); j++)
+ {
+ for (k = exstyle = 0; k < COUNTOF(exStyles); k++) if (j & (1 << k)) exstyle |= exStyles[k];
+ SetRect( &rect, 100, 100, 200, 200 );
+ rect2 = rect;
+ AdjustWindowRectEx( &rect, style, FALSE, exstyle );
+ wine_AdjustWindowRectEx( &rect2, style, FALSE, exstyle );
+ ok( EqualRect( &rect, &rect2 ), "rects do not match: win %d,%d-%d,%d wine %d,%d-%d,%d\n",
+ rect.left, rect.top, rect.right, rect.bottom,
+ rect2.left, rect2.top, rect2.right, rect2.bottom );
+ }
+ }
+}
#undef COUNTOF
#define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
@@ -4803,6 +4874,7 @@ static void test_AdjustWindowRect(void)
test_AWR_window_size(FALSE);
test_AWR_window_size(TRUE);
+ test_AWR_flags();
DestroyMenu(hmenu);
}
More information about the wine-cvs
mailing list