Skip to content

fix: correct window sizing on Linux when constraints on resizability are enforced - #49903

Merged
jkleinsc merged 6 commits into
electron:mainfrom
mitchchn:mitch/fix-linux-resizability-and-constraints
Feb 27, 2026
Merged

jkleinsc merged 6 commits into
electron:mainfrom
mitchchn:mitch/fix-linux-resizability-and-constraints

Conversation

@mitchchn

@mitchchn mitchchn commented Feb 21, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Followup to #49835, which normalized bounds operations on Linux to use logical coordinates. That PR left two edge cases where windows could still draw at the wrong sizes if certain properties were set on the browser window:

  1. Max size constraints

Windows with max width and height constraints appeared smaller than they should be. This is because Chromium calls GetMinimumSize and GetMaximumSize directly and expects them to use widget's total coordinate space, not the logical max window size. To account for this, these methods need to inflate constraints by insets on Linux. This is now handled by the tree host for all Linux frame classes to keep this quirk away from the rest of the API.

  1. Resizable property

Setting resizable: false was causing the window to grow taller on Linux in some configurations. I traced this down to a couple related issues in setResizable:

  • Code which was supposed to be Linux-specific was not actually gated to Linux, so it was running unnecessarily on Windows as well.
  • Content size constraints were being applied to the window. This caused ClientFrameViewLinux to change its height whenever this method is called.

I gated the Linux-specific logic and updated it to use window size constraints to prevent resizability, which is the right thing to do even if content size is in use. I also tested for resizability regressions on Windows with frame: true/false, thickFrame: true/false, and transparent: true/false.

(Note: On X11 or Wayland environments with SSD, the window manager draws the frame externally, so a framed window will still be taller than whatever height/max height is requested This is expected and not a bug introduced in this PR.)

Fixes #49902.

Checklist

Release Notes

Notes: Fixed window sizing on Linux when min/max size constraints are set or resizable is false. Windows no longer shrink below the requested max size or grow taller when resizability is disabled.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Feb 21, 2026
@mitchchn mitchchn changed the title fix: correct window sizing on Linux when constraints or resizability are enforced fix: correct window sizing on Linux when constraints on resizability are enforced Feb 21, 2026

@jkleinsc jkleinsc 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.

These changes appear to have broken Windows testing

@mitchchn
mitchchn requested a review from jkleinsc February 26, 2026 01:53
@mitchchn

Copy link
Copy Markdown
Member Author

@jkleinsc 949e2ee makes setResizable work more like other window style setters on Windows. If it's too much of a change in this PR I can put back the previous impl, but it passes the tests and worked in my own testing on Windows.

Comment on lines -967 to -972
SetContentSizeConstraints(old_size_constraints_);
SetSizeConstraints(old_size_constraints_);
} else {
old_size_constraints_ = GetContentSizeConstraints();
gfx::Size content_size = GetContentSize();
SetContentSizeConstraints(
extensions::SizeConstraints(content_size, content_size));

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.

@mitchchn why is this code no longer necessary on non Linux OSes?

@mitchchn mitchchn Feb 26, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So leaving aside Mac because it doesn't use this class: the existing code makes a compromise that isn't accurate for Linux, and only works for Windows in a roundabout way.

Windows controls resizability with window styles (WS_THICKFRAME, WS_MAXIMIZEBOX). The code worked before because setting size constraints (to any value) triggers SizeConstraintsChanged in Chromium. That method does reapply window styles including resizability, but it doesn't depend on the actual constraint values changing or their state in this class.

Linux otoh does depend on the specific value of the size constraints and their cached state, but it needs to use window size constraints instead of content size otherwise some kinds of windows will shrink.

Another option is to bring the code back for Windows, but still change it to use window size constraints instead of content size This would fix Linux but still need to be tested on Windows. But it's a more conservative change if you'd rather I try it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Trying the less invasive approach: 2ddce9b. I also updated the test that guards against window size changes to cover Windows.

@jkleinsc

Copy link
Copy Markdown
Member

@mitchchn my main concern here is that logic that is currently running on all OSes has been removed/changed. Unless there's a good reason for these changes, I'd prefer that this PR just address the issue specifically for Linux.

@jkleinsc jkleinsc added semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 27, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 27, 2026
@jkleinsc
jkleinsc merged commit 6a440f0 into electron:main Feb 27, 2026
65 checks passed
@release-clerk

release-clerk Bot commented Feb 27, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed window sizing on Linux when min/max size constraints are set or resizable is false. Windows no longer shrink below the requested max size or grow taller when resizability is disabled.

trop Bot added a commit that referenced this pull request Feb 27, 2026
…are enforced (#49903)

* fix window sizing on linux when constraints are applied

* added tests

* apply window style directly when changing resizability

* Revert "apply window style directly when changing resizability"

This reverts commit 949e2ee.

* set size constraints for resizability on window and linux

Co-authored-by: Mitchell Cohen <[email protected]>
@trop

trop Bot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

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

@trop trop Bot added in-flight/41-x-y and removed target/41-x-y PR should also be added to the "41-x-y" branch. labels Feb 27, 2026
@electron-cation electron-cation Bot added new-pr 🌱 PR opened recently and removed new-pr 🌱 PR opened recently labels Feb 27, 2026
codebytere pushed a commit that referenced this pull request Mar 2, 2026
…are enforced (#49971)

fix: correct window sizing on Linux when constraints on resizability are enforced (#49903)

* fix window sizing on linux when constraints are applied

* added tests

* apply window style directly when changing resizability

* Revert "apply window style directly when changing resizability"

This reverts commit 949e2ee.

* set size constraints for resizability on window and linux

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Mitchell Cohen <[email protected]>
@trop trop Bot added merged/41-x-y PR was merged to the "41-x-y" branch. and removed in-flight/41-x-y labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/41-x-y PR was merged to the "41-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wayland: some frame configurations still have incorrect bounds

2 participants