Remove visual artifacts of hidden-inset window
This commit is contained in:
parent
79b507bda6
commit
e90435e236
2 changed files with 17 additions and 15 deletions
|
@ -78,7 +78,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
UpdateDraggableRegionViews(draggable_regions_);
|
UpdateDraggableRegionViews(draggable_regions_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldHideNativeToolbarInFullscreen() const {
|
bool should_hide_native_toolbar_in_fullscreen() const {
|
||||||
return should_hide_native_toolbar_in_fullscreen_;
|
return should_hide_native_toolbar_in_fullscreen_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,26 +176,30 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
- (void)windowWillEnterFullScreen:(NSNotification*)notification {
|
||||||
if (shell_->ShouldHideNativeToolbarInFullscreen()) {
|
// Hide the native toolbar before entering fullscreen, so there is no visual
|
||||||
|
// artifacts.
|
||||||
|
if (shell_->should_hide_native_toolbar_in_fullscreen()) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
NSWindow* window = shell_->GetNativeWindow();
|
||||||
[window setToolbar:nil];
|
[window setToolbar:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_->NotifyWindowEnterFullScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
|
||||||
|
shell_->NotifyWindowEnterFullScreen();
|
||||||
|
|
||||||
// Restore the native toolbar for styling if needed
|
// Restore the native toolbar immediately after entering fullscreen, if we do
|
||||||
if (shell_->ShouldHideNativeToolbarInFullscreen()) {
|
// this before leaving fullscreen, traffic light buttons will be jumping.
|
||||||
|
if (shell_->should_hide_native_toolbar_in_fullscreen()) {
|
||||||
NSWindow* window = shell_->GetNativeWindow();
|
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];
|
||||||
[window setToolbar:toolbar];
|
[window setToolbar:toolbar];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)windowDidExitFullScreen:(NSNotification*)notification {
|
||||||
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];
|
||||||
|
@ -349,7 +353,8 @@ NativeWindowMac::NativeWindowMac(
|
||||||
const mate::Dictionary& options)
|
const mate::Dictionary& options)
|
||||||
: NativeWindow(web_contents, options),
|
: NativeWindow(web_contents, options),
|
||||||
is_kiosk_(false),
|
is_kiosk_(false),
|
||||||
attention_request_id_(0) {
|
attention_request_id_(0),
|
||||||
|
should_hide_native_toolbar_in_fullscreen_(false) {
|
||||||
int width = 800, height = 600;
|
int width = 800, height = 600;
|
||||||
options.Get(options::kWidth, &width);
|
options.Get(options::kWidth, &width);
|
||||||
options.Get(options::kHeight, &height);
|
options.Get(options::kHeight, &height);
|
||||||
|
@ -392,14 +397,11 @@ NativeWindowMac::NativeWindowMac(
|
||||||
styleMask |= NSFullSizeContentViewWindowMask;
|
styleMask |= NSFullSizeContentViewWindowMask;
|
||||||
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
styleMask |= NSUnifiedTitleAndToolbarWindowMask;
|
||||||
}
|
}
|
||||||
|
// We capture this because we need to access the option later when
|
||||||
// We capture this because we need to access the option later when entering/exiting fullscreen
|
// entering/exiting fullscreen and since the options dict is only passed to
|
||||||
// and since the options dict is only passed to the constructor but not stored,
|
// the constructor but not stored, let’s store this option this way.
|
||||||
// let’s store this option this way.
|
|
||||||
if (titleBarStyle == "hidden-inset") {
|
if (titleBarStyle == "hidden-inset") {
|
||||||
should_hide_native_toolbar_in_fullscreen_ = true;
|
should_hide_native_toolbar_in_fullscreen_ = true;
|
||||||
} else {
|
|
||||||
should_hide_native_toolbar_in_fullscreen_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window_.reset([[AtomNSWindow alloc]
|
window_.reset([[AtomNSWindow alloc]
|
||||||
|
|
Loading…
Add table
Reference in a new issue