Repository navigation
fix: Inset maximized client area to work area on Win32 - #23562
Conversation
Custom-chrome (extend-into-titlebar) windows remove the system frame in WM_NCCALCSIZE, but a maximized resizable window is positioned so its resize frame overhangs the monitor on every edge. The client area (and the caption buttons) therefore spilled off-screen, and AppWindow.ClientSize / Window.Bounds / XamlRoot.Bounds over-reported. The previous compensation was a hard-coded, DPI-unaware WindowChrome.Padding = 4 fudge. Correct it natively: when maximized (and not full-screen), clamp the proposed client rect to the monitor work area in WM_NCCALCSIZE so the client becomes exactly the visible, non-taskbar region - matching a standard maximized window and WinUI - with no frame/DPI math. An auto-hide taskbar reserves no work area, so reserve 1px on any edge hosting one (via SHAppBarMessage) so it can still be revealed. The WindowChrome.Padding hack and the dead _offScreenMargins / _extendedMargins are removed. Also fix non-client caption/drag-region hit-testing to map region rects through the real client origin (ClientToScreen) instead of the window origin, which only coincided while full-bleed; once the client is inset they diverged by the frame thickness. closes #21745 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AYJwArDyoGhNWJ6Zy79Z3e
Regression test for #21745: a maximized window with an extended title bar must have its client area inset from the (overhanging) window rect. Before the fix the client equalled the window (off-screen bleed); after, it is strictly smaller by the resize-frame thickness per side. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AYJwArDyoGhNWJ6Zy79Z3e
|
Claude finished @MartinZikmund's task in 5m 39s —— View job PR Review: fix: Inset maximized client area to work area on Win32
Overall verdict: ✅ Approved with minor fixesThe approach is correct and well-motivated. Moving the maximized-overhang correction to the native 3 findings — 2 minor, 1 nit:
Specific notes
Test: The Validation: Code-review assessment only (no local Win32 build environment). The PR description documents manual validation at 150% DPI with |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23562/wasm-skia-net9/index.html |
|
|
- Add #nullable enable to Win32AutoHideTaskbar.cs (new file) - Remove dead borderCaptionThickness.left negation Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WngCVWr7iSBMzbjMjvKRQz
|
Claude finished @MartinZikmund's task in 4m 53s —— View job PR Review: fix: Inset maximized client area to work area on Win32
Overall verdict: ✅ ApprovedAll three findings from the previous review pass have been correctly addressed in Previous findings — status
Code inspection notes
Test —
Validation: Code-review only (no local Win32 build environment). Current CI shows no failures on this commit. |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23562/wasm-skia-net9/index.html |
GitHub Issue: closes #21745
PR Type:
🐞 Bugfix
What changed? 🚀
On Win32 (Skia), custom-chrome windows (
ExtendsContentIntoTitleBar = true, or no presenter title bar) strip the system frame by returning0fromWM_NCCALCSIZE, making the client area equal to the window rect. When such a window is maximized, Windows positions it so its resize frame overhangs the monitor on every edge (~8px/side at 100% DPI, more when scaled). The previous behaviour therefore let the content and caption buttons spill off-screen, andAppWindow.ClientSize/Window.Bounds/XamlRoot.Boundsover-reported. The only compensation was a hard-coded, DPI-unawareWindowChrome.Padding = 4fudge.This moves the correction to the native level, so
WindowChromefills the full screen and the reported sizes match a maximized WinUI app on the same screen:WM_NCCALCSIZE: when the window is maximized (and not full-screen), clamp the proposed client rect to the monitor work area (client = window ∩ rcWork). This makes the client exactly the visible, non-taskbar region — identical to a standard maximized window and to WinUI — with no frame-thickness/DPI math (which is off by a pixel and caption-sensitive). The monitor is taken from the proposed rect, so it is correct on a secondary monitor and during restore-from-minimized.SHAppBarMessage/ABM_GETAUTOHIDEBAREX), matching the native WinUI windowing layer.WindowChrome.Padding = 4hack and the now-dead_offScreenMargins/_extendedMargins.ClientToScreen) instead of the window origin. The two coincided only while full-bleed; once the client is inset they diverged by the frame thickness, which would have misplaced the caption-button hit zones.FullScreenPresenter(which also reports a maximized window viaSW_MAXIMIZE) is explicitly excluded so it keeps owning the whole monitor. Standard windows (with a system title bar + border) are untouched — they fall through toDefWindowProcas before.Validation (Skia Win32,
AppWindowPositionAndSizesample, 150% DPI): with the title bar extended and the window maximized, the client area is now exactly the monitor work area (dW=0, dH=0) while the window rect overhangs by 2×frame; the caption buttons render at the true top-right corner and clicking the maximize/restore button correctly restores the window (confirming hit-test alignment). A runtime regression test (Given_AppWindow.When_Maximized_With_Extended_TitleBar_Client_Is_Inset_From_Window) asserts the client is inset from the overhanging window rect.The approach was cross-checked against WPF (
SetWindowRgntorcWork), WinUI (client == work-area contract) and Avalonia (NCCALCSIZE inset).PR Checklist ✅
Screenshots Compare Test Runresults.