diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 3a3b3c6efc80..bcf6ccc5a335 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -219,10 +219,6 @@ void Window::OnWindowMoved() { Emit("moved"); } -void Window::OnWindowWillEnterFullScreen(bool* prevent_default) { - *prevent_default = Emit("will-enter-full-screen"); -} - void Window::OnWindowEnterFullScreen() { Emit("enter-full-screen"); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 2d1e6d71ec34..641124f4dfd2 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -67,7 +67,6 @@ class Window : public mate::TrackableObject, void OnWindowMoved() override; void OnWindowScrollTouchBegin() override; void OnWindowScrollTouchEnd() override; - void OnWindowWillEnterFullScreen(bool* prevent_default) override; void OnWindowEnterFullScreen() override; void OnWindowLeaveFullScreen() override; void OnWindowEnterHtmlFullScreen() override; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index a09705fbd967..273bd948fe52 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -134,10 +134,16 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { 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) { @@ -445,13 +451,6 @@ void NativeWindow::NotifyWindowMoved() { FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowMoved()); } -bool NativeWindow::RequestEnterFullScreen() { - bool prevent_default = false; - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowWillEnterFullScreen(&prevent_default)); - return prevent_default; -} - void NativeWindow::NotifyWindowEnterFullScreen() { FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowEnterFullScreen()); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 4cc04e790e1e..09fae6c6bcfe 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -197,9 +197,6 @@ class NativeWindow : public base::SupportsUserData, // Requests the WebContents to close, can be cancelled by the page. virtual void RequestToClosePage(); - // Request the WebContents to go fullscreen, can be cancelled by the page. - virtual bool RequestEnterFullScreen(); - // Methods called by the WebContents. virtual void CloseContents(content::WebContents* source); virtual void RendererUnresponsive(content::WebContents* source); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index f4f5a8c97899..7967a1771735 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -602,9 +602,6 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) { if (fullscreen == IsFullscreen()) return; - if (fullscreen && RequestEnterFullScreen()) - return; - if (!base::mac::IsOSLionOrLater()) { LOG(ERROR) << "Fullscreen mode is only supported above Lion"; return; diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 1f66bac5b634..4af181085a08 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -52,7 +52,6 @@ class NativeWindowObserver { virtual void OnWindowMoved() {} virtual void OnWindowScrollTouchBegin() {} virtual void OnWindowScrollTouchEnd() {} - virtual void OnWindowWillEnterFullScreen(bool* prevent_default) {} virtual void OnWindowEnterFullScreen() {} virtual void OnWindowLeaveFullScreen() {} virtual void OnWindowEnterHtmlFullScreen() {} diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 101c57515af1..4b3b32024df0 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_); @@ -347,14 +348,10 @@ bool NativeWindowViews::IsMinimized() { } void NativeWindowViews::SetFullScreen(bool fullscreen) { - bool prevent_default = false; - if (fullscreen) - prevent_default = RequestEnterFullScreen(); - #if defined(OS_WIN) // There is no native fullscreen state on Windows. if (fullscreen) { - if (!prevent_default) { + if (IsFullScreenable()) { last_window_state_ = ui::SHOW_STATE_FULLSCREEN; NotifyWindowEnterFullScreen(); } @@ -364,10 +361,10 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) { } // We set the new value after notifying, so we can handle the size event // correctly. - if (!prevent_default) + if (IsFullScreenable()) window_->SetFullscreen(fullscreen); #else - if (!(fullscreen && prevent_default)) { + if (!fullscreen || IsFullScreenable()) { if (IsVisible()) window_->SetFullscreen(fullscreen); else @@ -499,11 +496,15 @@ bool NativeWindowViews::IsMaximizable() { #endif } -void NativeWindowViews::SetFullScreenable(bool maximizable) { +void NativeWindowViews::SetFullScreenable(bool fullscreenable) { + #if defined(OS_WIN) + FlipWindowStyle(GetAcceleratedWidget(), false, WS_MAXIMIZEBOX); + #endif + 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 934f2aa00c93..862cd5458bb6 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 827bb84db810..96ce955db595 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -276,11 +276,6 @@ __Note__: On OS X this event is just an alias of `moved`. Emitted once when the window is moved to a new position. -### Event: 'will-enter-full-screen' - -Emitted when the window is about to enter full screen state. Calling `event.preventDefault()` -will cancel the state change. - ### Event: 'enter-full-screen' Emitted when the window enters full screen state. @@ -589,17 +584,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_