8000 Bound the target width and height of window when calling SetSize by MarshallOfSound · Pull Request #6363 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bound the target width and height of window when calling SetSize #6363

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

Merged
merged 2 commits into from
Jul 7, 2016

Conversation

MarshallOfSound
Copy link
Member

This fixes #6347 by bounding the width and height values by the MinimumSize and MaximumSize bounds of the window.

@MarshallOfSound MarshallOfSound force-pushed the master branch 2 times, most recently from e72ce7a to c81699c Compare July 6, 2016 12:28
@zcbenz
Copy link
8000
Contributor
zcbenz commented Jul 6, 2016

Doing this in atom/browser/native_window_mac.mm should be enough, on Windows and Linux this has been enforced with the UI library of Chromium, doing it in NativeWindow can also avoid adding code to all size related APIs since we only need to check in constructor and SetBounds.

@MarshallOfSound
Copy link
Member Author

@zcbenz Was just writing up a comment querying if that would be the case 😆

I'll quickly transpose this into the mac native window file. 👍

@MarshallOfSound
Copy link
Member Author

🎉 Magic 😆

It's now in native window mac 👍

@@ -756,6 +756,17 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
return bounds;
}

void NativeWindowMac::SetSize(const gfx::Size& size, bool animate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

All size APIs are directly to the SetBounds method, so we only need to do check there.

bSize.SetToMax(GetMinimumSize());

gfx::Size maxSize = GetMaximumSize();
maxSize = gfx::Size(maxSize.width() == 0 ? bSize.width() : maxSize.width(),
Copy link
Member Author

Choose a reason for hiding this comment

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

We couldn't use a straight up SetToMin call here as for some reason Electron's default maximumSize is [0, 0]. This means we need these nasty ternary operatorst

@MarshallOfSound
Copy link
Member Author

🎉 Magic 😆

It's now in SetBounds 👍

@zcbenz
Copy link
Contributor
zcbenz commented Jul 7, 2016

👍

@zcbenz zcbenz merged commit 43e9f30 into electron:master Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
< 480E /div> None yet
Development

Successfully merging this pull request may close these issues.

Calling setSize can override minimum width values
2 participants
0