fix: enforce size constraints on window creation on Windows and Linux#49906
Conversation
ckerr
left a comment
There was a problem hiding this comment.
These CI failures eg. here seem related to the PR:
Failure in test: "BrowserWindow module sizing BrowserWindow.setMinimum/MaximumSize(width, height) creates window at max size when a larger size is requested"
AssertionError: expected 184 to equal 200
Same test failure on windows-arm64, windows-x86, and windows-x64
…e-size-constraints-on-init
Fixed! |
|
@mitchchn the bots want |
Only 41 and up. |
jkleinsc
left a comment
There was a problem hiding this comment.
Looks like mac arm64 tests are failing. Can you rebase this PR to see if that resolves those failing tests?
…e-size-constraints-on-init
jkleinsc
left a comment
There was a problem hiding this comment.
Looks like this change is causing mac arm64 mas tests to fail. I'm not sure why its failing but it does look like the removed code would have executed on mac so maybe its needed there.
…e-size-constraints-on-init
…e-size-constraints-on-init
…itchchn/electron into mitch/enforce-size-constraints-on-init
|
@jkleinsc yup, that test caught a subtle bug and I did need to put back a condition I removed. (Not sure why it only failed on ARM64/MAS...) |
|
Needs rereview from @jkleinsc |
|
Release Notes Persisted
|
…#49906) * enforce size constraints on window creation * set constraints after resizing on init * restore conditional centering Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
…#49906) * enforce size constraints on window creation * set constraints after resizing on init * restore conditional centering Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
|
I have automatically backported this PR to "41-x-y", please check out #50753 |
|
I have automatically backported this PR to "42-x-y", please check out #50754 |
…#50754) fix: enforce size constraints on window creation on Windows and Linux (#49906) * enforce size constraints on window creation * set constraints after resizing on init * restore conditional centering Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
…#50753) fix: enforce size constraints on window creation on Windows and Linux (#49906) * enforce size constraints on window creation * set constraints after resizing on init * restore conditional centering Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Mitchell Cohen <mitch.cohen@me.com>
Description of Change
I noticed that size constraints were not enforced properly on window creation on Linux and Windows:
In some environments, this simply creates a window that is too small. In others, the conflict is resolved by the window manager on show, but not before the window gets centered in the wrong position (and initially reports the wrong size).
This PR applies all size constraints on init and moves centering/positioning so it happens after the final window size has been determined.
Checklist
npm testpassesRelease Notes
Notes: BrowserWindow now enforces min/max size constraints on window creation, even if they conflict with the requested width and height.