Skip to content

fix: correct bounds and constraints on Windows for framed and frameless windows#51179

Closed
mitchchn wants to merge 4 commits into
electron:mainfrom
mitchchn:mitch/fix-exact-bounds-and-constraints-windows
Closed

fix: correct bounds and constraints on Windows for framed and frameless windows#51179
mitchchn wants to merge 4 commits into
electron:mainfrom
mitchchn:mitch/fix-exact-bounds-and-constraints-windows

Conversation

@mitchchn

@mitchchn mitchchn commented Apr 20, 2026

Copy link
Copy Markdown
Member

Description of Change

Fixes #50783.

This PR regularizes bounds and constraints handling on Windows so that windows are created at their exact expected sizes and can grow and shrink to exact max/min constraints. Previously sizes be off by 8-16px because insets weren't always accounted for on creation or after various lifecycle events.

Bound/inset logic is fragile and hard to reason about, so I added about a dozen cross-platform constraint tests which run for both framed and frameless windows to help prevent regressions.

As was the case on Linux, the underlying issues originate in Chromium, which does not experience them as severely since it usually only enforces minimum sizes and it rarely changes bounds or constraints programmatically. The solution requires two Chromium patches:

  1. A new patch which accounts for insets when clamping bounds to size constraints in DesktopWindowTreeHostWin::AdjustedContentBounds.
  2. An update to an earlier patch from @CezaryKulakowski (fix: aspect ratio when max width/height is set #29101) which now corrects for insets when setting the aspect ratio.
    (This patch needs to use lower level DWM code since it does not have access to the frame.)

I was able to upstream the relevant patches when working on this problem for Linux, and I'll also attempt to upstream both of my changes as well as the previous work from @CezaryKulakowski.

Checklist

Release Notes

Notes: Fixed an issue on Windows where windows appeared smaller than their configured size or were unable to be resized to their maximum size constraints.

@mitchchn mitchchn requested a review from a team as a code owner April 20, 2026 17:48
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Apr 20, 2026
@mitchchn

Copy link
Copy Markdown
Member Author

/request-review @codebytere,@ckerr

@mitchchn mitchchn force-pushed the mitch/fix-exact-bounds-and-constraints-windows branch 5 times, most recently from e50ce18 to 52c5efc Compare April 21, 2026 01:53
@mitchchn mitchchn marked this pull request as draft April 21, 2026 15:37
@mitchchn mitchchn force-pushed the mitch/fix-exact-bounds-and-constraints-windows branch 5 times, most recently from ba41105 to 5334862 Compare April 22, 2026 03:35
@mitchchn mitchchn force-pushed the mitch/fix-exact-bounds-and-constraints-windows branch from 5334862 to c3ec3d2 Compare April 26, 2026 14:18
@mitchchn

Copy link
Copy Markdown
Member Author

Getting some feedback upstream before proceeding with this: https://chromium-review.googlesource.com/c/chromium/src/+/7795073

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Apr 27, 2026
@mitchchn mitchchn closed this May 9, 2026
tobias-jarvelov added a commit to mullvad/mullvadvpn-app that referenced this pull request May 18, 2026
The window is 16px less in width and 8px less in height than the what
we have set as the window bounds,

Likely related to the following issue:
electron/electron#50783

See also:
electron/electron#51179
electron/electron#50706
tobias-jarvelov added a commit to mullvad/mullvadvpn-app that referenced this pull request May 18, 2026
The window is 16px less in width and 8px less in height than the what
we have set as the window bounds,

Likely related to the following issue:
electron/electron#50783

See also:
electron/electron#51179
electron/electron#50706
tobias-jarvelov added a commit to mullvad/mullvadvpn-app that referenced this pull request May 21, 2026
The window is 16px less in width and 8px less in height than the what
we have set as the window bounds,

Likely related to the following issue:
electron/electron#50783

See also:
electron/electron#51179
electron/electron#50706
tobias-jarvelov added a commit to mullvad/mullvadvpn-app that referenced this pull request Jun 4, 2026
The window is 16px less in width and 8px less in height than the what
we have set as the window bounds,

Likely related to the following issue:
electron/electron#50783

See also:
electron/electron#51179
electron/electron#50706
tobias-jarvelov added a commit to mullvad/mullvadvpn-app that referenced this pull request Jun 4, 2026
The window is 16px less in width and 8px less in height than the what
we have set as the window bounds,

Likely related to the following issue:
electron/electron#50783

See also:
electron/electron#51179
electron/electron#50706
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 with frame: true are smaller than they should be on Windows

1 participant