#52012: fix: frameless window shrinks on maximize() when compositor declines
Description of Change
On Wayland, BrowserWindow.maximize() on a frameless / titleBarStyle:hidden / WCO window shrinks the window by ~30x41px each call when the compositor ignores xdg_toplevel.set_maximized (sway floating windows, any tiling WM).
Ozone calls PlatformWindowDelegate::CalculateInsetsInDIP(window_state) twice per configure — once in HandleToplevelConfigureWithOrigin to outset the compositor geometry to widget bounds, and again in SetWindowGeometry to inset back — and assumes both calls return the same value for the same window_state. Our override returns GetRestoredFrameBorderInsets() for kNormal, which reaches FrameViewLayoutLinux::GetShadowValues() and reads widget->IsMaximized(). TriggerStateChanges()' optimistic ForceApplyWindowStateDoNotUse(kMaximized) is live for the first call and reverted by the second, so the insets are ~2x1 then ~32x42 and the geometry round-trip loses 30x41px.
Stop delegating to the base GetShadowValues() and compute the restored shadow values directly, so "restored" insets describe the restored state regardless of current widget state. Painting is unaffected: the maximized and fullscreen paint paths don't consult GetShadowValues(), and GetFrameBorderInsets() has its own IsMaximized() guard.
Also quiets the xdg_toplevel.set_min_size (2,1)<->(1,1) flutter on every maximize() which had the same cause.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixes an issue where clicking the maximize button could progressively shrink the window in some Wayland environments.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron