From b444211d6f96cf9738f5097bd6deb86790de2544 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 7 Jun 2016 17:26:26 +0900 Subject: [PATCH] Fix title of frameless window showing as empty under fullscreen --- atom/browser/native_window_mac.h | 3 +++ atom/browser/native_window_mac.mm | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index c1694c3..52ebcbc 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -139,6 +139,9 @@ class NativeWindowMac : public NativeWindow { // The presentation options before entering kiosk mode. NSApplicationPresentationOptions kiosk_options_; + // The window title, for frameless windows we only set title when fullscreen. + std::string title_; + // Force showing the buttons for frameless window. bool force_show_buttons_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 8bc4052..2b88b18 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -193,10 +193,16 @@ bool ScopedDisableResize::disable_resize_ = false; - (void)windowDidEnterFullScreen:(NSNotification*)notification { shell_->NotifyWindowEnterFullScreen(); + // For frameless window we don't set title for normal mode since the title + // bar is expected to be empty, but after entering fullscreen mode we have + // to set one, because title bar is visible here. + NSWindow* window = shell_->GetNativeWindow(); + if (shell_->transparent() || !shell_->has_frame()) + [window setTitle:base::SysUTF8ToNSString(shell_->GetTitle())]; + // Restore the native toolbar immediately after entering fullscreen, if we do // this before leaving fullscreen, traffic light buttons will be jumping. if (shell_->should_hide_native_toolbar_in_fullscreen()) { - NSWindow* window = shell_->GetNativeWindow(); base::scoped_nsobject toolbar( [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [toolbar setShowsBaselineSeparator:NO]; @@ -209,6 +215,11 @@ bool ScopedDisableResize::disable_resize_ = false; } - (void)windowWillExitFullScreen:(NSNotification*)notification { + // Restore the title bar to empty. + NSWindow* window = shell_->GetNativeWindow(); + if (shell_->transparent() || !shell_->has_frame()) + [window setTitle:@""]; + // Turn off the style for toolbar. if (shell_->should_hide_native_toolbar_in_fullscreen()) shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); @@ -781,6 +792,8 @@ void NativeWindowMac::Center() { } void NativeWindowMac::SetTitle(const std::string& title) { + title_ = title; + // We don't want the title to show in transparent or frameless window. if (transparent() || !has_frame()) return; @@ -789,7 +802,7 @@ void NativeWindowMac::SetTitle(const std::string& title) { } std::string NativeWindowMac::GetTitle() { - return base::SysNSStringToUTF8([window_ title]); + return title_; } void NativeWindowMac::FlashFrame(bool flash) { -- 2.7.4