diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index dc9f0f6a152e..122c5a68624d 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -381,8 +381,10 @@ std::vector Window::GetMaximumSize() { return result; } -void Window::SetSheetOffset(double offset) { - window_->SetSheetOffset(offset); +void Window::SetSheetOffset(double offsetY, mate::Arguments* args) { + double offsetX = 0.0; + args->GetNext(&offsetX); + window_->SetSheetOffset(offsetX, offsetY); } void Window::SetResizable(bool resizable) { diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 7746dd8d7681..f174cdba88c6 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -111,7 +111,7 @@ class Window : public mate::TrackableObject, std::vector GetMinimumSize(); void SetMaximumSize(int width, int height); std::vector GetMaximumSize(); - void SetSheetOffset(double offset); + void SetSheetOffset(double offsetY, mate::Arguments* args); void SetResizable(bool resizable); bool IsResizable(); void SetMovable(bool movable); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 23a434a81b45..31567c197508 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -52,7 +52,8 @@ NativeWindow::NativeWindow( enable_larger_than_screen_(false), is_closed_(false), has_dialog_attached_(false), - sheet_offset_(0.0), + sheet_offset_x_(0.0), + sheet_offset_y_(0.0), aspect_ratio_(0.0), inspectable_web_contents_(inspectable_web_contents), weak_factory_(this) { @@ -250,12 +251,17 @@ gfx::Size NativeWindow::GetMaximumSize() { return GetSizeConstraints().GetMaximumSize(); } -void NativeWindow::SetSheetOffset(const double offset) { - sheet_offset_ = offset; +void NativeWindow::SetSheetOffset(const double offsetX, const double offsetY) { + sheet_offset_x_ = offsetX; + sheet_offset_y_ = offsetY; } -double NativeWindow::GetSheetOffset() { - return sheet_offset_; +double NativeWindow::GetSheetOffsetX() { + return sheet_offset_x_; +} + +double NativeWindow::GetSheetOffsetY() { + return sheet_offset_y_; } void NativeWindow::SetRepresentedFilename(const std::string& filename) { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 6a96c013e79e..7bc432d45deb 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -123,8 +123,9 @@ class NativeWindow : public base::SupportsUserData, virtual gfx::Size GetMinimumSize(); virtual void SetMaximumSize(const gfx::Size& size); virtual gfx::Size GetMaximumSize(); - virtual void SetSheetOffset(const double offset); - virtual double GetSheetOffset(); + virtual void SetSheetOffset(const double offsetX, const double offsetY); + virtual double GetSheetOffsetX(); + virtual double GetSheetOffsetY(); virtual void SetResizable(bool resizable) = 0; virtual bool IsResizable() = 0; virtual void SetMovable(bool movable) = 0; @@ -316,8 +317,10 @@ class NativeWindow : public base::SupportsUserData, // it should be cancelled when we can prove that the window is responsive. base::CancelableClosure window_unresposive_closure_; - // Used to display sheets at the appropriate vertical offset - double sheet_offset_; + // Used to display sheets at the appropriate horizontal and vertical offsets + // on OS X. + double sheet_offset_x_; + double sheet_offset_y_; // Used to maintain the aspect ratio of a view which is inside of the // content view. diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index bfffc7a08d64..333b282266f5 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -257,7 +257,9 @@ bool ScopedDisableResize::disable_resize_ = false; - (NSRect)window:(NSWindow*)window willPositionSheet:(NSWindow*)sheet usingRect:(NSRect)rect { NSView* view = window.contentView; - rect.origin.y = view.frame.size.height - shell_->GetSheetOffset(); + + rect.origin.x = shell_->GetSheetOffsetX(); + rect.origin.y = view.frame.size.height - shell_->GetSheetOffsetY(); return rect; } diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index aa21e5fd59ad..0bd38dec560e 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -683,7 +683,7 @@ Returns the title of the native window. **Note:** The title of web page can be different from the title of the native window. -### `win.setSheetOffset(offset)` _OS X_ +### `win.setSheetOffset(offsetY[, offsetX])` _OS X_ Changes the attachment point for sheets on Mac OS X. By default, sheets are attached just below the window frame, but you may want to display them beneath