Fixes #2810: correct look of hidden-inset windows in full screen.
`hidden` and `hidden-inset` windows differ only by the hidden-inset window having a toolbar. Yet, the toolbar yields an incorrect look in fullscreen mode. So, we hide and recreate the toolbar for such windows when going to/from fullscreen. There are some visible artifacts during the fullscreen animations, as the toolbar gets created and destroyed. When entering fullscreen, you see a toolbar that then disappears. When going back to normal window, you see the traffic light buttons jump around a little bit. Yet, this is definitely better than the current broken fullscreen look.
This commit is contained in:
parent
c68e38f480
commit
aa2f7aaf3a
2 changed files with 30 additions and 0 deletions
|
@ -78,6 +78,10 @@ class NativeWindowMac : public NativeWindow {
|
||||||
UpdateDraggableRegionViews(draggable_regions_);
|
UpdateDraggableRegionViews(draggable_regions_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShouldHideNativeToolbarInFullscreen() const {
|
||||||
|
return should_hide_native_toolbar_in_fullscreen_;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// NativeWindow:
|
// NativeWindow:
|
||||||
void HandleKeyboardEvent(
|
void HandleKeyboardEvent(
|
||||||
|
@ -118,6 +122,8 @@ class NativeWindowMac : public NativeWindow {
|
||||||
// The presentation options before entering kiosk mode.
|
// The presentation options before entering kiosk mode.
|
||||||
NSApplicationPresentationOptions kiosk_options_;
|
NSApplicationPresentationOptions kiosk_options_;
|
||||||
|
|
||||||
|
bool should_hide_native_toolbar_in_fullscreen_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -177,10 +177,25 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
||||||
|
if (shell_->ShouldHideNativeToolbarInFullscreen()) {
|
||||||
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
|
[window setToolbar:nil];
|
||||||
|
}
|
||||||
|
|
||||||
shell_->NotifyWindowEnterFullScreen();
|
shell_->NotifyWindowEnterFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
||||||
|
|
||||||
|
// Restore the native toolbar for styling if needed
|
||||||
|
if (shell_->ShouldHideNativeToolbarInFullscreen()) {
|
||||||
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
|
base::scoped_nsobject<NSToolbar> toolbar(
|
||||||
|
[[NSToolbar alloc] initWithIdentifier:@"titlebarStylingToolbar"]);
|
||||||
|
[toolbar setShowsBaselineSeparator:NO];
|
||||||
|
[window setToolbar:toolbar];
|
||||||
|
}
|
||||||
|
|
||||||
if (!shell_->has_frame()) {
|
if (!shell_->has_frame()) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
|
[[window standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
|
||||||
|
@ -378,6 +393,15 @@ NativeWindowMac::NativeWindowMac(
|
||||||
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We capture this because we need to access the option later when entering/exiting fullscreen
|
||||||
|
// and since the options dict is only passed to the constructor but not stored,
|
||||||
|
// let’s store this option this way.
|
||||||
|
if (titleBarStyle == "hidden-inset") {
|
||||||
|
should_hide_native_toolbar_in_fullscreen_ = true;
|
||||||
|
} else {
|
||||||
|
should_hide_native_toolbar_in_fullscreen_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
window_.reset([[AtomNSWindow alloc]
|
window_.reset([[AtomNSWindow alloc]
|
||||||
initWithContentRect:cocoa_bounds
|
initWithContentRect:cocoa_bounds
|
||||||
styleMask:styleMask
|
styleMask:styleMask
|
||||||
|
|
Loading…
Add table
Reference in a new issue