diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 7af5e6e2d7e4..fad41417755a 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -366,6 +366,12 @@ gfx::Rect Window::GetBounds() { return window_->GetBounds(); } +void Window::SetContentBounds(const gfx::Rect& bounds, mate::Arguments* args) { + bool animate = false; + args->GetNext(&animate); + window_->SetContentBounds(bounds, animate); +} + gfx::Rect Window::GetContentBounds() { return window_->GetContentBounds(); } @@ -790,6 +796,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("getSize", &Window::GetSize) .SetMethod("setSize", &Window::SetSize) .SetMethod("getContentBounds", &Window::GetContentBounds) + .SetMethod("setContentBounds", &Window::SetContentBounds) .SetMethod("getContentSize", &Window::GetContentSize) .SetMethod("setContentSize", &Window::SetContentSize) .SetMethod("setMinimumSize", &Window::SetMinimumSize) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 056b4cae347d..e027ceabc7c6 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -112,6 +112,7 @@ class Window : public mate::TrackableObject, std::vector GetSize(); void SetContentSize(int width, int height, mate::Arguments* args); std::vector GetContentSize(); + void SetContentBounds(const gfx::Rect& bounds, mate::Arguments* args); gfx::Rect GetContentBounds(); void SetMinimumSize(int width, int height); std::vector GetMinimumSize(); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 86a402b766b5..3a3bc685b79c 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -228,6 +228,10 @@ gfx::Size NativeWindow::GetContentSize() { return GetContentBounds().size(); } +void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) { + SetBounds(ContentBoundsToWindowBounds(bounds), animate); +} + gfx::Rect NativeWindow::GetContentBounds() { return WindowBoundsToContentBounds(GetBounds()); } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 84663ead6278..352297223f2e 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -91,6 +91,7 @@ class NativeWindow : public base::SupportsUserData, virtual gfx::Point GetPosition(); virtual void SetContentSize(const gfx::Size& size, bool animate = false); virtual gfx::Size GetContentSize(); + virtual void SetContentBounds(const gfx::Rect& bounds, bool animate = false); virtual gfx::Rect GetContentBounds(); virtual void SetSizeConstraints( const extensions::SizeConstraints& size_constraints); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index d96d3aeeaba9..583a297cf63f 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1045,10 +1045,15 @@ std::vector NativeWindowMac::CalculateNonDraggableRegions( gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds( const gfx::Rect& bounds) { - if (has_frame()) - return gfx::Rect([window_ frameRectForContentRect:bounds.ToCGRect()]); - else + if (has_frame()) { + gfx::Rect window_bounds( + [window_ frameRectForContentRect:bounds.ToCGRect()]); + int frame_height = window_bounds.height() - bounds.height(); + window_bounds.set_y(window_bounds.y() - frame_height); + return window_bounds; + } else { return bounds; + } } gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(