[PATCH v2 0/1] MR11099: Draft: win32u/tests: Add a test for maximizing captionless windows.
This test is specifically for testing the expansion of 5 pixels beyond the monitor and work area when a window is maximized. -- v2: win32u/tests: Add a test for maximizing captionless x11 windows. https://gitlab.winehq.org/wine/wine/-/merge_requests/11099
From: Jacob Czekalla <jczekalla@codeweavers.com> This test is specifically for testing the expansion of 5 pixels beyond the monitor and work area when an x11 window is maximized. --- dlls/win32u/tests/win32u.c | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index 4481ffa1b32..ce747b543b8 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -3004,6 +3004,132 @@ static void test_NtUserRegisterWindowMessage(void) ok( !wcscmp( buf, L"#0xabc" ), "buf = %s\n", debugstr_w(buf) ); } +struct maximize_test +{ + const char *name; + BOOL is_todo; + RECT test_rect; + RECT expected_rect; +}; +static RECT maximize_rect = { 0 }; +static LRESULT WINAPI test_over_maximize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_GETMINMAXINFO: + { + MONITORINFO mi; + MINMAXINFO *mmi = (MINMAXINFO *)lparam; + HMONITOR monitor; + RECT rect = maximize_rect; + + if ((rect.left | rect.right | rect.top | rect.bottom) == 0) + break; + + mi.cbSize = sizeof(mi); + + monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + if (!monitor || !GetMonitorInfoW(monitor, &mi)) + break; + + InflateRect(&rect, 5, 5); + + mmi->ptMaxPosition.x = rect.left - mi.rcMonitor.left; + mmi->ptMaxPosition.y = rect.top - mi.rcMonitor.top; + + mmi->ptMaxSize.x = rect.right - rect.left; + mmi->ptMaxSize.y = rect.bottom - rect.top; + + mmi->ptMaxTrackSize.x = mmi->ptMaxSize.x; + mmi->ptMaxTrackSize.y = mmi->ptMaxSize.y; + + return 0; + } + default: + break; + } + return DefWindowProcW(hwnd, msg, wparam, lparam); +} + +static void test_no_caption_maximize(void) +{ + HWND hwnd; + WNDCLASSW cls = { 0 }; + MONITORINFO monitor_info = { sizeof ( MONITORINFO ) }; + HMONITOR monitor; + DWORD style, i; + struct maximize_test tests[2]; + HMODULE ntdll; + RECT rc; + + cls.lpfnWndProc = test_over_maximize_proc; + cls.hInstance = GetModuleHandleW(NULL); + cls.lpszClassName = L"maximize_test"; + RegisterClassW(&cls); + + hwnd = CreateWindowW(L"maximize_test", NULL, WS_OVERLAPPEDWINDOW, 50, 50, 100, 100, 0, NULL, GetModuleHandleW(NULL), NULL); + if (!hwnd) + return; + + ntdll = GetModuleHandleA("ntdll.dll"); + if (ntdll && GetProcAddress(ntdll, "wine_get_version") && !GetModuleHandleA("winex11.drv")) + { + skip("Skipping x11 maximize test.\n"); + DestroyWindow(hwnd); + return; + } + + style = GetWindowLongW(hwnd, GWL_STYLE); + style &= ~WS_CAPTION; + SetWindowLongW(hwnd, GWL_STYLE, style); + SetWindowPos(hwnd, NULL, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_FRAMECHANGED); + flush_events(); + + monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); + if (!monitor || !GetMonitorInfoW(monitor, &monitor_info)) + { + DestroyWindow(hwnd); + return; + } + + /* test cases */ + tests[0].name = "monitor"; + tests[0].test_rect = monitor_info.rcMonitor; + tests[0].expected_rect = monitor_info.rcMonitor; + tests[0].is_todo = FALSE; + InflateRect(&tests[0].expected_rect, 5, 5); + + tests[1].name = "work area"; + tests[1].test_rect = monitor_info.rcWork; + tests[1].expected_rect = monitor_info.rcWork; + tests[1].is_todo = TRUE; + InflateRect(&tests[1].expected_rect, 5, 5); + + for (i = 0; i < ARRAY_SIZE(tests); i++) + { + maximize_rect = tests[i].test_rect; + + if (IsZoomed(hwnd)) + { + ShowWindow(hwnd, SW_RESTORE); + flush_events(); + } + + ShowWindow(hwnd, SW_MAXIMIZE); + flush_events(); + + GetWindowRect(hwnd, &rc); + todo_wine_if(tests[i].is_todo) + ok(EqualRect(&tests[i].expected_rect, &rc), "%s: expected %s got %s\n", tests[i].name, wine_dbgstr_rect(&tests[i].expected_rect), wine_dbgstr_rect(&rc)); + style = GetWindowLongW(hwnd, GWL_STYLE); + ok(style & WS_MAXIMIZE, "%s: style incorrect, missing WS_MAXIMIZE.\n", tests[i].name); + } + + DestroyWindow(hwnd); +} + START_TEST(win32u) { char **argv; @@ -3049,6 +3175,7 @@ START_TEST(win32u) test_timer(); test_inter_process_messages( argv[0] ); test_wndproc_hook(); + test_no_caption_maximize(); test_NtUserCloseWindowStation(); test_NtUserDisplayConfigGetDeviceInfo(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11099
Dmitry Timoshkov (@dmitry) commented about dlls/win32u/tests/win32u.c:
+ cls.lpfnWndProc = test_over_maximize_proc; + cls.hInstance = GetModuleHandleW(NULL); + cls.lpszClassName = L"maximize_test"; + RegisterClassW(&cls); + + hwnd = CreateWindowW(L"maximize_test", NULL, WS_OVERLAPPEDWINDOW, 50, 50, 100, 100, 0, NULL, GetModuleHandleW(NULL), NULL); + if (!hwnd) + return; + + ntdll = GetModuleHandleA("ntdll.dll"); + if (ntdll && GetProcAddress(ntdll, "wine_get_version") && !GetModuleHandleA("winex11.drv")) + { + skip("Skipping x11 maximize test.\n"); + DestroyWindow(hwnd); + return; + } What's the point of this test if it doesn't test the Windows behaviour?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142536
On Tue Jun 9 16:20:37 2026 +0000, Dmitry Timoshkov wrote:
What's the point of this test if it doesn't test the Windows behaviour? The test still runs on Windows, so it should verify the Windows behavior. The driver check is only to make sure that x11 is being used when the test runs on wine.
As there is no test suite for x11 drivers I thought here would be the best spot. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142537
On Tue Jun 9 16:46:25 2026 +0000, Jacob Czekalla wrote:
The test still runs on Windows, so it should verify the Windows behavior. The driver check is only to make sure that x11 is being used when the test runs on wine. As there is no test suite for x11 drivers I thought here would be the best spot. The best place for testing windows behaviour is dlls/user32/tests, and X11 specific behaviour shouldn't matter. What are you trying to test exactly?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142539
On Tue Jun 9 16:50:56 2026 +0000, Dmitry Timoshkov wrote:
The best place for testing windows behaviour is dlls/user32/tests, and X11 specific behaviour shouldn't matter. What are you trying to test exactly? I am trying to test when an application provides a maximized rect through WM_GETMINMAXINFO that is larger than the working area.
My WM does not allow this and tries to clamp it down, but on Windows, this over extended maximized rect is allowed. This test is to show the difference between the behavior. I can see now though, that it passes and that this type of test may not work as intended when run through the pipeline. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142540
On Tue Jun 9 17:06:03 2026 +0000, Jacob Czekalla wrote:
I am trying to test when an application provides a maximized rect through WM_GETMINMAXINFO that is larger than the working area. My WM does not allow this and tries to clamp it down, but on Windows, this over extended maximized rect is allowed. This test is to show the difference between the behavior. I can see now though, that it passes and that this type of test may not work as intended when run through the pipeline. We already have some bugs related to WM_GETMINMAXINFO handling, and under X11 it's impossible for an application to provide custom rectangle for a top level window: https://bugs.winehq.org/show_bug.cgi?id=5941 https://bugs.winehq.org/show_bug.cgi?id=47715#c2
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142541
On Tue Jun 9 17:26:05 2026 +0000, Dmitry Timoshkov wrote:
We already have some bugs related to WM_GETMINMAXINFO handling, and under X11 it's impossible for an application to provide custom rectangle for a top level window: https://bugs.winehq.org/show_bug.cgi?id=5941 https://bugs.winehq.org/show_bug.cgi?id=47715#c2 Ahh I see, thank you for the info. It looks like this issue is well known and possibly messy. I am going to close this MR for now as it looks like there won't be a nice solution I can get up-streamed.
Thanks :3 -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099#note_142544
This merge request was closed by Jacob Czekalla. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11099
participants (3)
-
Dmitry Timoshkov (@dmitry) -
Jacob Czekalla -
Jacob Czekalla (@JacobCzekalla)