From 13bfb099a2d23c302d43e26829a8fbf7a571dc2d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 17 May 2016 16:19:28 +0900 Subject: [PATCH] Fix the toolbar showing when titleBarStyle is hidden-inset --- atom/browser/native_window_mac.h | 8 ++++---- atom/browser/native_window_mac.mm | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 5ad4f39e722..22390f42dd0 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -91,6 +91,10 @@ class NativeWindowMac : public NativeWindow { UpdateDraggableRegionViews(draggable_regions_); } + // Set the attribute of NSWindow while work around a bug of zoom button. + void SetStyleMask(bool on, NSUInteger flag); + void SetCollectionBehavior(bool on, NSUInteger flag); + bool should_hide_native_toolbar_in_fullscreen() const { return should_hide_native_toolbar_in_fullscreen_; } @@ -120,10 +124,6 @@ class NativeWindowMac : public NativeWindow { // whehter we can drag. void UpdateDraggableRegionViews(const std::vector& regions); - // Set the attribute of NSWindow while work around a bug of zo0m button. - void SetStyleMask(bool on, NSUInteger flag); - void SetCollectionBehavior(bool on, NSUInteger flag); - base::scoped_nsobject window_; base::scoped_nsobject window_delegate_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 4a646a9eb93..0f782d58516 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -214,10 +214,22 @@ bool ScopedDisableResize::disable_resize_ = false; [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [toolbar setShowsBaselineSeparator:NO]; [window setToolbar:toolbar]; + + // Set window style to hide the toolbar, otherwise the toolbar will show in + // fullscreen mode. + shell_->SetStyleMask(true, NSFullSizeContentViewWindowMask); } } +- (void)windowWillExitFullScreen:(NSNotification*)notification { + // Turn off the style for toolbar. + if (shell_->should_hide_native_toolbar_in_fullscreen()) + shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); +} + - (void)windowDidExitFullScreen:(NSNotification*)notification { + // For certain versions of OS X the fullscreen button will automatically show + // after exiting fullscreen mode. if (!shell_->has_frame()) { NSWindow* window = shell_->GetNativeWindow(); [[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES]; @@ -486,7 +498,7 @@ NativeWindowMac::NativeWindowMac( [window_ setReleasedWhenClosed:NO]; // Hide the title bar. - if ((titleBarStyle == "hidden") || (titleBarStyle == "hidden-inset")) { + if (titleBarStyle == "hidden-inset") { [window_ setTitlebarAppearsTransparent:YES]; [window_ setTitleVisibility:NSWindowTitleHidden]; if (titleBarStyle == "hidden-inset") {