8000 fix: update traffic lights position for macOS 11 by trop[bot] · Pull Request #30269 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: update traffic lights position for macOS 11 #30269

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
[buttons_view_ setShowOnHover:YES];
if (title_bar_style_ == TitleBarStyle::kHiddenInset &&
!traffic_light_position_)
[buttons_view_ setMargin:gfx::Point(12, 11)];
[buttons_view_ setMargin:[WindowButtonsView hiddenInsetMargin]];

if (!IsClosable())
[[buttons_view_ viewWithTag:0] setEnabled:NO];
Expand Down
2 changes: 2 additions & 0 deletions shell/browser/ui/cocoa/window_buttons_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
base::scoped_nsobject<NSTrackingArea> tracking_area_;
}

+ (gfx::Point)defaultMargin;
+ (gfx::Point)hiddenInsetMargin;
- (id)initWithMargin:(const absl::optional<gfx::Point>&)margin;
- (void)setMargin:(const absl::optional<gfx::Point>&)margin;
- (void)setShowOnHover:(BOOL)yes;
Expand Down
17 changes: 16 additions & 1 deletion shell/browser/ui/cocoa/window_buttons_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@

@implementation WindowButtonsView

+ (gfx::Point)defaultMargin {
if (@available(macOS 11.0, *)) {
return gfx::Point(7, 6);
} else {
return gfx::Point(7, 3);
}
}

+ (gfx::Point)hiddenInsetMargin {
// For macOS >= 11, while this value does not match offical macOS apps like
// Safari or Notes, it matches titleBarStyle's old implementation before
// Electron <= 12.
return gfx::Point(12, 11);
}

- (id)initWithMargin:(const absl::optional<gfx::Point>&)margin {
self = [super initWithFrame:NSZeroRect];
[self setMargin:margin];
Expand Down Expand Up @@ -51,7 +66,7 @@ - (id)initWithMargin:(const absl::optional<gfx::Point>&)margin {
}

- (void)setMargin:(const absl::optional<gfx::Point>&)margin {
margin_ = margin.value_or(gfx::Point(7, 3));
margin_ = margin.value_or([WindowButtonsView defaultMargin]);
}

- (void)setShowOnHover:(BOOL)yes {
Expand Down
0