Skip to content

Sync Windows fullscreen client size and preserve hidden-titlebar DWM borders - #105

Merged
lijy91 merged 1 commit into
mainfrom
fix/windows-fullscreen-hidden-titlebar-issue-60
Dec 1, 2026
Merged

lijy91 merged 1 commit into
mainfrom
fix/windows-fullscreen-hidden-titlebar-issue-60

Conversation

@lijy91

@lijy91 lijy91 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Fixes libnativeapi/nativeapi#60.

Root Cause

  1. Entering and exiting borderless fullscreen on Windows updated outer window bounds and styles, but SWP_NOSIZE | SWP_FRAMECHANGED after SetWindowPlacement did not reliably re-emit WM_SIZE with the post-frame-change client rect or force an immediate child repaint, leaving child surfaces such as Flutter's FLUTTERVIEW unsized or overflowing until a focus change (Alt+Tab).
  2. When leaving fullscreen on a TitleBarStyle::Hidden window, dwm.exe detaches non-client rendering in fullscreen (WM_DWMNCRENDERINGCHANGED with wParam = FALSE) and only re-attaches asynchronously after SetFullScreen(false) returns. During that transition window, SWP_FRAMECHANGED sends WM_NCPAINT with wParam = 1, causing DefWindowProcW (and DrawMenuBar) to paint classic Aero Basic / Windows 7 caption and border pixels onto the window's redirection bitmap.

Changes

  • Added SyncFullScreenClientArea in src/platform/windows/window_windows.cpp to deliver WM_SIZE with the final GetClientRect and immediately invalidate/update client and child windows on both fullscreen entry and exit.
  • Tracked WM_DWMNCRENDERINGCHANGED (0x031F) via kDwmNcDisabledProperty; while detached on a compositor-framed TitleBarStyle::Hidden window, preserved the top client band across untouched DefSubclassProc(WM_NCPAINT) and cleared non-client resize borders (WindowRect - ClientRect) to transparent black (plus once on WM_DWMNCRENDERINGCHANGED(TRUE)), preserving Windows 11 rounded corners and shadow with zero classic title bar flash or border residue.
  • Suppressed WM_NCUAHDRAWCAPTION / WM_NCUAHDRAWFRAME on all hidden-title-bar windows, skipped DrawMenuBar when the title bar is hidden, and collapsed the redundant second SWP_FRAMECHANGED in SetFullScreen(false).
  • Added tests/window_fullscreen_hidden_titlebar_windows_test.cpp verifying normal and maximized fullscreen round-trips, child surface sizing, zero top-band classic caption overdraw, and transparent DWM resize borders.

@lijy91
lijy91 force-pushed the fix/windows-fullscreen-hidden-titlebar-issue-60 branch from bc754a4 to bbfb708 Compare November 30, 2026 23:55
@lijy91 lijy91 changed the title Sync Windows fullscreen client size and clip hidden-titlebar WM_NCPAINT Sync Windows fullscreen client size and preserve hidden-titlebar DWM borders Nov 30, 2026
@lijy91
lijy91 force-pushed the fix/windows-fullscreen-hidden-titlebar-issue-60 branch from bbfb708 to cb2f41a Compare December 1, 2026 00:02
@lijy91
lijy91 merged commit e06e9f6 into main Dec 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: window.isFullScreen leaves Flutter surface unsized / blank until focus change (0.6.2)

1 participant