Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: respect minimizable/closable for customButtonsOnHover #18485

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion atom/browser/native_window_mac.h
Expand Up @@ -165,7 +165,7 @@ class NativeWindowMac : public NativeWindow {

private:
// Add custom layers to the content view.
void AddContentViewLayers();
void AddContentViewLayers(bool minimizable, bool closable);

void InternalSetParentWindow(NativeWindow* parent, bool attach);
void SetForwardMouseMessages(bool forward);
Expand Down
22 changes: 15 additions & 7 deletions atom/browser/native_window_mac.mm
Expand Up @@ -73,9 +73,11 @@ - (id)initWithFrame:(NSRect)frame {
NSButton* close_button =
[NSWindow standardWindowButton:NSWindowCloseButton
forStyleMask:NSWindowStyleMaskTitled];
[close_button setTag:1];
NSButton* miniaturize_button =
[NSWindow standardWindowButton:NSWindowMiniaturizeButton
forStyleMask:NSWindowStyleMaskTitled];
[miniaturize_button setTag:2];

CGFloat x = 0;
const CGFloat space_between = 20;
Expand Down Expand Up @@ -459,7 +461,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {

// Default content view.
SetContentView(new views::View());
AddContentViewLayers();
AddContentViewLayers(minimizable, closable);

original_frame_ = [window_ frame];
original_level_ = [window_ level];
Expand Down Expand Up @@ -851,9 +853,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
[window_ setLevel:newLevel];
} else {
*error = std::string([
[NSString stringWithFormat:@"relativeLevel must be between %d and %d",
minWindowLevel, maxWindowLevel] UTF8String]);
*error = std::string([[NSString
stringWithFormat:@"relativeLevel must be between %d and %d",
minWindowLevel, maxWindowLevel] UTF8String]);
}
}

Expand Down Expand Up @@ -1092,7 +1094,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

[view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView()
removeFromSuperview];
removeFromSuperview];
remove_browser_view(view);

[CATransaction commit];
Expand Down Expand Up @@ -1374,7 +1376,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
return root_view_.get();
}

void NativeWindowMac::AddContentViewLayers() {
void NativeWindowMac::AddContentViewLayers(bool minimizable, bool closable) {
// Make sure the bottom corner is rounded for non-modal windows:
// http://crbug.com/396264.
if (!is_modal()) {
Expand Down Expand Up @@ -1414,6 +1416,12 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
[[CustomWindowButtonView alloc] initWithFrame:NSZeroRect]);
// NSWindowStyleMaskFullSizeContentView does not work with zoom button
SetFullScreenable(false);

if (!minimizable)
[[buttons_view_ viewWithTag:2] removeFromSuperview];
if (!closable)
[[buttons_view_ viewWithTag:1] removeFromSuperview];

[[window_ contentView] addSubview:buttons_view_];
} else {
if (title_bar_style_ != NORMAL)
Expand Down Expand Up @@ -1470,7 +1478,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[container_view_ setFrame:[[[window_ contentView] superview] bounds]];
[window_ setContentView:container_view_];
AddContentViewLayers();
AddContentViewLayers(IsMinimizable(), IsClosable());
}

void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
Expand Down