Fix title of frameless window showing as empty under fullscreen

This commit is contained in:
Cheng Zhao 2016-06-07 17:26:26 +09:00
parent d3d2ca9a31
commit b444211d6f
2 changed files with 18 additions and 2 deletions

View file

@ -139,6 +139,9 @@ class NativeWindowMac : public NativeWindow {
// The presentation options before entering kiosk mode. // The presentation options before entering kiosk mode.
NSApplicationPresentationOptions kiosk_options_; 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. // Force showing the buttons for frameless window.
bool force_show_buttons_; bool force_show_buttons_;

View file

@ -193,10 +193,16 @@ bool ScopedDisableResize::disable_resize_ = false;
- (void)windowDidEnterFullScreen:(NSNotification*)notification { - (void)windowDidEnterFullScreen:(NSNotification*)notification {
shell_->NotifyWindowEnterFullScreen(); 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 // Restore the native toolbar immediately after entering fullscreen, if we do
// this before leaving fullscreen, traffic light buttons will be jumping. // this before leaving fullscreen, traffic light buttons will be jumping.
if (shell_->should_hide_native_toolbar_in_fullscreen()) { if (shell_->should_hide_native_toolbar_in_fullscreen()) {
NSWindow* window = shell_->GetNativeWindow();
base::scoped_nsobject<NSToolbar> toolbar( base::scoped_nsobject<NSToolbar> toolbar(
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]); [[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
[toolbar setShowsBaselineSeparator:NO]; [toolbar setShowsBaselineSeparator:NO];
@ -209,6 +215,11 @@ bool ScopedDisableResize::disable_resize_ = false;
} }
- (void)windowWillExitFullScreen:(NSNotification*)notification { - (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. // Turn off the style for toolbar.
if (shell_->should_hide_native_toolbar_in_fullscreen()) if (shell_->should_hide_native_toolbar_in_fullscreen())
shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask); shell_->SetStyleMask(false, NSFullSizeContentViewWindowMask);
@ -781,6 +792,8 @@ void NativeWindowMac::Center() {
} }
void NativeWindowMac::SetTitle(const std::string& title) { void NativeWindowMac::SetTitle(const std::string& title) {
title_ = title;
// We don't want the title to show in transparent or frameless window. // We don't want the title to show in transparent or frameless window.
if (transparent() || !has_frame()) if (transparent() || !has_frame())
return; return;
@ -789,7 +802,7 @@ void NativeWindowMac::SetTitle(const std::string& title) {
} }
std::string NativeWindowMac::GetTitle() { std::string NativeWindowMac::GetTitle() {
return base::SysNSStringToUTF8([window_ title]); return title_;
} }
void NativeWindowMac::FlashFrame(bool flash) { void NativeWindowMac::FlashFrame(bool flash) {