diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index d07d586a843..f357663fd1e 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -46,6 +46,7 @@ class NativeWindowMac : public NativeWindow { bool IsFullscreen() const override; void SetBounds(const gfx::Rect& bounds, bool animate = false) override; gfx::Rect GetBounds() override; + void SetSize(const gfx::Size& size, bool animate = false) override; void SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) override; void SetResizable(bool resizable) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 1ef003ab2aa..58836c4ea4e 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -756,6 +756,17 @@ gfx::Rect NativeWindowMac::GetBounds() { return bounds; } +void NativeWindowMac::SetSize(const gfx::Size& size, bool animate) { + gfx::Size minSize = GetMinimumSize(); + gfx::Size maxSize = GetMaximumSize(); + // Bound the supplied width and height values with max and min sizes + int bWidth = fmax(minSize.width(), size.width()); + bWidth = maxSize.width() == 0 ? bWidth : fmin(maxSize.width(), bWidth); + int bHeight = fmax(minSize.height(), size.height()); + bHeight = maxSize.height() == 0 ? bHeight : fmin(maxSize.height(), bHeight); + SetBounds(gfx::Rect(GetPosition(), gfx::Size(bWidth, bHeight)), animate); +} + void NativeWindowMac::SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) { auto convertSize = [this](const gfx::Size& size) {