New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: maximized state calculation for non-resizable windows #30989
Conversation
Thank you PR, I did the checkout locally but found it only solved the second problem and not the first major one. When resizable is true (the default), I leave the window maximized while moving it around a bit and you will see that this fix does not do anything. You can use the gist address (gist/BlackHole1/b67e544) mentioned in #30979 to reproduce the problem locally. |
@BlackHole1 yes, that is why this specifically says "partially addresses". The primary issue may not be fixable owing to the way that Cocoa calculates window maximization, but i will continue to try. |
@codebytere thx for your answer.
What I'm going to say next is in response to the first question which has nothing to do with this PR. If we're going to try to solve the first problem, I think we need to establish one thing. Is maximizing after the
Only when this concept is clarified should we consider whether to fix the first problem. By the behavior of NsWindow.isZoomed, we can infer two possibilities.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the documentation of isZoomed
:
The zoomed state of the window is determined using the following steps:
If the delegate or the window class implements windowWillUseStandardFrame(_:defaultFrame:), it is invoked to obtain the zoomed frame of the window. The value of isZoomed is then determined by whether or not the current window frame is equal to the zoomed frame.
So I think the correct fix should be tweaking windowWillUseStandardFrame:defaultFrame:
to return the correct size of maximized window, instead of doing the calculation in NativeWindowMac::IsMaximized
.
Also the current implementation of NativeWindowMac::IsMaximized
has a special case for unresizable window, which should also be done in windowWillUseStandardFrame
.
@zcbenz can you elaborate a bit more on what you mean? I'm not sure that would work for non-resizable windows, since |
I didn't know that, this change makes sense to me now 👍 |
Release Notes Persisted
|
I have automatically backported this PR to "13-x-y", please check out #31039 |
I have automatically backported this PR to "14-x-y", please check out #31040 |
I have automatically backported this PR to "15-x-y", please check out #31041 |
Description of Change
Partially addresses #30979.
Fixes an issue where non-resizable non-fullscreenable windows with aspect ratios set could return incorrect results for
isMaximized()
. macOS callswindowWillUseStandardFrame:defaultFrame
with what it refers to as the "best fit" frame for agiven zoom (see Discussion Section). This means that even if an aspect ratio is set, macOS might adjust it to better fit the screen. Thus, we can't just calculate the maximized aspect ratio'd sizing from the current visible screen and compare that to the current window's frame to determine whether a window is maximized in
isMaximized
.Checklist
npm test
passesRelease Notes
Notes: Fixes an issue where non-resizable non-fullscreenable windows with aspect ratios set could return incorrect results for
isMaximized()
.