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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions atom/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,21 @@ static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
}

void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
gfx::Size bSize = gfx::Size(bounds.width(), bounds.height());
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

maxSize.height() == 0 ? bSize.height() : maxSize.height());
bSize.SetToMin(maxSize);

NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0,
bounds.width(),
bounds.height());
bSize.width(),
bSize.height());
// Flip coordinates based on the primary screen.
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
cocoa_bounds.origin.y =
NSHeight([screen frame]) - bounds.height() - bounds.y();
NSHeight([screen frame]) - bSize.height() - bounds.y();

[window_ setFrame:cocoa_bounds display:YES animate:animate];
}
Expand Down
0