Skip to content

fix: frameless windows do not shrink after constraints are applied on Windows - #51562

Merged
jkleinsc merged 1 commit into
electron:mainfrom
mitchchn:inflate-constraints-by-insets-windows
Jun 5, 2026
Merged

jkleinsc merged 1 commit into
electron:mainfrom
mitchchn:inflate-constraints-by-insets-windows

Conversation

@mitchchn

@mitchchn mitchchn commented May 8, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Fixes #51465.
Fixes #51876.

Replaces #51499. This PR requires a Chromium patch to backport: https://chromium-review.googlesource.com/c/chromium/src/+/7795073.)

Checklist

Release Notes

Notes: Fixed an issue where frameless windows windows could shrink after applying constraints or toggling resizability on Windows.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 8, 2026
@mitchchn mitchchn changed the title added inset correction and resizability bounds tests fix: frameless windows do not shrink after constraints are applied on Windows May 8, 2026
@mitchchn
mitchchn force-pushed the inflate-constraints-by-insets-windows branch 2 times, most recently from b51831f to 5df35cd Compare May 9, 2026 22:56
@mitchchn

mitchchn commented May 10, 2026 •

Copy link
Copy Markdown
Member Author

/request-review @ckerr

@ckerr, @mlaurencin: Since the main fixes were upstreamed, this PR is mostly tests with a small change to the GetContentSizeConstraints to inflate by insets, since size constraints are stored without them (this is not new but it didn't matter until frameless windows had insets).

I was almost able to get rid of the overrides for GetContentSizeConstraints and WindowToContentSizeBuggy completely, as Chromium’s impl is no longer “buggy.” I couldn’t manage that just yet because Electron still needs to have special handling for the menu bar height, but I will follow up with a small refactor which relies more on upstream sizing and constraints.

@gdavidkov

Copy link
Copy Markdown
Contributor

FYI: Chromium CL 7795073 (22167afbecda05…) is already present in this PR's target Chromium — main is pinned to 150.0.7834.0, and ui/views/win/hwnd_util.cc on that branch already exports InflateClientSizeConstraintsInPixels. So no separate Chromium-side backport is required for this PR to land on main; only the Electron-side changes here are needed.

The CL still needs to be cherry-picked manually for older release lines whose Chromium predates it — I've put one up for 42-x-y at #51622 (Chromium 148 there, doesn't have the CL natively) so #51465 can be fully resolved on that release once this PR lands.

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 15, 2026
@panther7

Copy link
Copy Markdown
Contributor

I can confirm, that this commit fixing this issue (tested on E42)

@mitchchn
mitchchn force-pushed the inflate-constraints-by-insets-windows branch from 5df35cd to 4056338 Compare May 20, 2026 19:17
@mitchchn

Copy link
Copy Markdown
Member Author

/request-review @mlaurencin

@mitchchn
mitchchn force-pushed the inflate-constraints-by-insets-windows branch 2 times, most recently from 6a75247 to 49af926 Compare May 30, 2026 21:13
@VerteDinde VerteDinde added the semver/patch backwards-compatible bug fixes label Jun 5, 2026

@mlaurencin mlaurencin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is worth blocking on, but this seems seem be fixed within 1-2px error margin for scale factors 1, 1.5, and 2. However, for 1.25 I am seeing an error of 4px on the x-axis. I am fine with merging this to fix the larger errors occurring, but given that 125% is the current recommended scale on Windows, it might be good to revisit.

@mlaurencin mlaurencin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually upon further inspection, it looks like the 125% issue on resizable true has been the case for a while now, it is just more apparent now that resizable false has been fixed. I still think it is worth looking into, but does not need to be addressed in this PR.

@mitchchn

mitchchn commented Jun 5, 2026 •

Copy link
Copy Markdown
Member Author

@mlaurencin thanks for testing. I intend to submit a DPI scaling solution separately. Yes, the scaling error is an issue that has existed for a long time but it’s more obvious now. I filed this last month: #51572 to track it.

The basic issue with DPI is that chromium uses a very imprecise rounding method for DIP/pixel conversions. I think it just does ceil.

An easy solution is to just replace the call with a float conversion at the lowest level in Chromium. It's a very small change but I don't know if it will be accepted upstream.

Alternatively it would be possible to write more code in Electron to use only px bounds methods on Windows, which would avoid conversion issues.

@jkleinsc
jkleinsc merged commit dea8837 into electron:main Jun 5, 2026
124 of 129 checks passed
@release-clerk

release-clerk Bot commented Jun 5, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where frameless windows windows could shrink after applying constraints or toggling resizability on Windows.

@oalfroukh

Copy link
Copy Markdown

Hi @jkleinsc

When do you think this fix will be backported to "42-x-y"?

@jkleinsc

Copy link
Copy Markdown
Member

/trop run backport-to 43-x-y

@trop

trop Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The backport process for this PR has been manually initiated - sending your PR to 43-x-y!

@trop

trop Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #51954

@mlaurencin

Copy link
Copy Markdown
Member

@oalfroukh 42-x-y needs #51622 to be merged before this PR can be backported

@trop

trop Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@mitchchn has manually backported this PR to "42-x-y", please check out #52366

@trop trop Bot added in-flight/42-x-y merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

44-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. no-backport semver/patch backwards-compatible bug fixes

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

Frameless non-resizable BrowserWindow reports incorrect bounds since v41.5.0. Electron window changes size when moving after using setResizable

8 participants