From 2be368bded41425fa682381e4e723970a74a2652 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 5 Mar 2016 21:38:06 +0900 Subject: [PATCH 1/2] SetFullScreen should not work at all when not fullscreenable This follows the logic of OS X. --- atom/browser/native_window_views.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index a0c2e3f170..93eb7b88d8 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -363,29 +363,27 @@ bool NativeWindowViews::IsMinimized() { } void NativeWindowViews::SetFullScreen(bool fullscreen) { + if (!IsFullScreenable()) + return; + #if defined(OS_WIN) // There is no native fullscreen state on Windows. if (fullscreen) { - if (IsFullScreenable()) { - last_window_state_ = ui::SHOW_STATE_FULLSCREEN; - NotifyWindowEnterFullScreen(); - } + 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. - if (IsFullScreenable()) - window_->SetFullscreen(fullscreen); + window_->SetFullscreen(fullscreen); #else - if (!fullscreen || (fullscreen && IsFullScreenable())) { - if (IsVisible()) - window_->SetFullscreen(fullscreen); - else - window_->native_widget_private()->ShowWithWindowState( - ui::SHOW_STATE_FULLSCREEN); - } + if (IsVisible()) + window_->SetFullscreen(fullscreen); + else + window_->native_widget_private()->ShowWithWindowState( + ui::SHOW_STATE_FULLSCREEN); #endif } From 114801d41242b162af786f9fefc0b646273210e3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 5 Mar 2016 21:54:41 +0900 Subject: [PATCH 2/2] Remove the duplicate logic on OS X --- atom/browser/native_window.cc | 11 +++++------ atom/browser/native_window_mac.mm | 14 ++------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 16154be6be..20400437fc 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -133,18 +133,17 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) { if (options.Get(options::kAlwaysOnTop, &top) && top) { SetAlwaysOnTop(true); } - - // Disable fullscreen button when 'fullscreenable' is false or 'fullscreen' - // is specified to false. + // Disable fullscreen button if '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; + // Overriden by 'fullscreenable'. + options.Get(options::kFullScreenable, &fullscreenable); SetFullScreenable(fullscreenable); - if (fullscreen) + if (fullscreen) { SetFullScreen(true); - + } bool skip; if (options.Get(options::kSkipTaskbar, &skip) && skip) { SetSkipTaskbar(skip); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 9d9f2a2392..3fc4547851 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -482,19 +482,9 @@ NativeWindowMac::NativeWindowMac( options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor); [window_ setDisableAutoHideCursor:disableAutoHideCursor]; - // 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); - - // Disable zoom button if window is not resizable - if (!maximizable) { + // Disable zoom button if window is not resizable. + if (!maximizable) SetMaximizable(false); - } NSView* view = inspectable_web_contents()->GetView()->GetNativeView(); [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];