fix: incorrect view ordering for customButtonsOnHover (#15997)

This commit is contained in:
Shelley Vohr 2018-12-10 12:27:38 -08:00 committed by Michelle Tilley
parent 9f472acf80
commit 15f8d15b1b
4 changed files with 21 additions and 18 deletions

View file

@ -63,7 +63,12 @@ void BrowserWindow::OverrideNSWindowContentView(
NSView* webView = iwc->GetView()->GetNativeView();
NSView* contentView = [window()->GetNativeWindow() contentView];
[webView setFrame:[contentView bounds]];
[contentView addSubview:webView];
// ensure that buttons view is floated to top of view hierarchy
NSArray* subviews = [contentView subviews];
NSView* last = subviews.lastObject;
[contentView addSubview:webView positioned:NSWindowBelow relativeTo:last];
[contentView viewDidMoveToWindow];
}

View file

@ -74,9 +74,7 @@
forStyleMask:NSTitledWindowMask];
NSButton* miniaturize_button =
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
forStyleMask:NSTitledWindowMask];
NSButton* zoom_button = [NSWindow standardWindowButton:NSWindowZoomButton
forStyleMask:NSTitledWindowMask];
forStyleMask:NSWindowStyleMaskTitled];
CGFloat x = 0;
const CGFloat space_between = 20;
@ -89,11 +87,7 @@
x += space_between;
[self addSubview:miniaturize_button];
[zoom_button setFrameOrigin:NSMakePoint(x, 0)];
x += space_between;
[self addSubview:zoom_button];
const auto last_button_frame = zoom_button.frame;
const auto last_button_frame = miniaturize_button.frame;
[self setFrameSize:NSMakeSize(last_button_frame.origin.x +
last_button_frame.size.width,
last_button_frame.size.height)];
@ -1361,6 +1355,8 @@ void NativeWindowMac::AddContentViewLayers() {
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
buttons_view_.reset(
[[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]);
// NSWindowStyleMaskFullSizeContentView does not work with zoom button
SetFullScreenable(false);
[[window_ contentView] addSubview:buttons_view_];
} else {
if (title_bar_style_ != NORMAL) {