diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index c25534f7f18..16154be6bea 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -133,12 +133,18 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { if (options.Get(options::kAlwaysOnTop, &top) && top) { SetAlwaysOnTop(true); } -#if defined(OS_MACOSX) || defined(OS_WIN) - bool fullscreen; - if (options.Get(options::kFullscreen, &fullscreen) && fullscreen) { + + // Disable fullscreen button when 'fullscreenable' is false or 'fullscreen' + // is specified to false. + bool fullscreenable = true; + options.Get(options::kFullScreenable, &fullscreenable); + bool fullscreen = false; + if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) + fullscreenable = false; + SetFullScreenable(fullscreenable); + if (fullscreen) SetFullScreen(true); - } -#endif + bool skip; if (options.Get(options::kSkipTaskbar, &skip) && skip) { SetSkipTaskbar(skip); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 97a2ee05a33..a0c2e3f170b 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -117,7 +117,8 @@ NativeWindowViews::NativeWindowViews( movable_(true), resizable_(true), maximizable_(true), - minimizable_(true) { + minimizable_(true), + fullscreenable_(true) { options.Get(options::kTitle, &title_); options.Get(options::kAutoHideMenuBar, &menu_bar_autohide_); @@ -365,21 +366,26 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) { #if defined(OS_WIN) // There is no native fullscreen state on Windows. if (fullscreen) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); + if (IsFullScreenable()) { + last_window_state_ = ui::SHOW_STATE_FULLSCREEN; + NotifyWindowEnterFullScreen(); + } } else { last_window_state_ = ui::SHOW_STATE_NORMAL; NotifyWindowLeaveFullScreen(); } // We set the new value after notifying, so we can handle the size event // correctly. - window_->SetFullscreen(fullscreen); -#else - if (IsVisible()) + if (IsFullScreenable()) window_->SetFullscreen(fullscreen); - else - window_->native_widget_private()->ShowWithWindowState( - ui::SHOW_STATE_FULLSCREEN); +#else + if (!fullscreen || (fullscreen && IsFullScreenable())) { + if (IsVisible()) + window_->SetFullscreen(fullscreen); + else + window_->native_widget_private()->ShowWithWindowState( + ui::SHOW_STATE_FULLSCREEN); + } #endif } @@ -505,11 +511,12 @@ bool NativeWindowViews::IsMaximizable() { #endif } -void NativeWindowViews::SetFullScreenable(bool maximizable) { +void NativeWindowViews::SetFullScreenable(bool fullscreenable) { + fullscreenable_ = fullscreenable; } bool NativeWindowViews::IsFullScreenable() { - return true; + return fullscreenable_; } void NativeWindowViews::SetClosable(bool closable) { diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 934f2aa00c9..862cd5458bb 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -212,6 +212,7 @@ class NativeWindowViews : public NativeWindow, bool resizable_; bool maximizable_; bool minimizable_; + bool fullscreenable_; std::string title_; gfx::Size widget_size_; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 2800ac38a04..6e1bc992539 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -58,9 +58,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `alwaysOnTop` Boolean - Whether the window should always stay on top of other windows. Default is `false`. * `fullscreen` Boolean - Whether the window should show in fullscreen. When - explicitly set to `false` the fullscreen button will be hidden or disabled - on OS X, or the maximize button will be disabled on Windows. Default is - `false`. + explicity set to `false` the fullscreen button will be hidden or disabled + on OS X. Default is `false`. * `fullscreenable` Boolean - Whether the maximize/zoom button on OS X should toggle full screen mode or maximize window. Default is `true`. * `skipTaskbar` Boolean - Whether to show the window in taskbar. Default is @@ -582,17 +581,17 @@ nothing. Returns whether the window can be manually maximized by user. On Linux always returns `true`. -### `win.setFullScreenable(fullscreenable)` _OS X_ +### `win.setFullScreenable(fullscreenable)` * `fullscreenable` Boolean Sets whether the maximize/zoom window button toggles fullscreen mode or -maximizes the window. On Windows and Linux does nothing. +maximizes the window. -### `win.isFullScreenable()` _OS X_ +### `win.isFullScreenable()` Returns whether the maximize/zoom window button toggles fullscreen mode or -maximizes the window. On Windows and Linux always returns `true`. +maximizes the window. ### `win.setClosable(closable)` _OS X_ _Windows_