fix: update traffic lights position for macOS 11 (#30263)
This commit is contained in:
parent
385d0f590f
commit
d2989de5d9
3 changed files with 19 additions and 2 deletions
|
@ -1800,7 +1800,7 @@ void NativeWindowMac::AddContentViewLayers() {
|
||||||
[buttons_view_ setShowOnHover:YES];
|
[buttons_view_ setShowOnHover:YES];
|
||||||
if (title_bar_style_ == TitleBarStyle::kHiddenInset &&
|
if (title_bar_style_ == TitleBarStyle::kHiddenInset &&
|
||||||
!traffic_light_position_)
|
!traffic_light_position_)
|
||||||
[buttons_view_ setMargin:gfx::Point(12, 11)];
|
[buttons_view_ setMargin:[WindowButtonsView hiddenInsetMargin]];
|
||||||
|
|
||||||
if (!IsClosable())
|
if (!IsClosable())
|
||||||
[[buttons_view_ viewWithTag:0] setEnabled:NO];
|
[[buttons_view_ viewWithTag:0] setEnabled:NO];
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
base::scoped_nsobject<NSTrackingArea> tracking_area_;
|
base::scoped_nsobject<NSTrackingArea> tracking_area_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (gfx::Point)defaultMargin;
|
||||||
|
+ (gfx::Point)hiddenInsetMargin;
|
||||||
- (id)initWithMargin:(const absl::optional<gfx::Point>&)margin;
|
- (id)initWithMargin:(const absl::optional<gfx::Point>&)margin;
|
||||||
- (void)setMargin:(const absl::optional<gfx::Point>&)margin;
|
- (void)setMargin:(const absl::optional<gfx::Point>&)margin;
|
||||||
- (void)setShowOnHover:(BOOL)yes;
|
- (void)setShowOnHover:(BOOL)yes;
|
||||||
|
|
|
@ -23,6 +23,21 @@ const NSWindowButton kButtonTypes[] = {
|
||||||
|
|
||||||
@implementation WindowButtonsView
|
@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 {
|
- (id)initWithMargin:(const absl::optional<gfx::Point>&)margin {
|
||||||
self = [super initWithFrame:NSZeroRect];
|
self = [super initWithFrame:NSZeroRect];
|
||||||
[self setMargin:margin];
|
[self setMargin:margin];
|
||||||
|
@ -51,7 +66,7 @@ const NSWindowButton kButtonTypes[] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMargin:(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 {
|
- (void)setShowOnHover:(BOOL)yes {
|
||||||
|
|
Loading…
Reference in a new issue