Skip to content

Commit

Permalink
fix: only bezel frameless windows (#23810)
Browse files Browse the repository at this point in the history
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed May 28, 2020
1 parent 4f2699f commit af12533
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1454,25 +1454,27 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
[effect_view setState:NSVisualEffectStateActive];

// Make frameless Vibrant windows have rounded corners.
CGFloat radius = 5.0f; // default corner radius
CGFloat dimension = 2 * radius + 1;
NSSize size = NSMakeSize(dimension, dimension);
NSImage* maskImage = [NSImage imageWithSize:size
flipped:NO
drawingHandler:^BOOL(NSRect rect) {
NSBezierPath* bezierPath = [NSBezierPath
bezierPathWithRoundedRect:rect
xRadius:radius
yRadius:radius];
[[NSColor blackColor] set];
[bezierPath fill];
return YES;
}];
[maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)];
[maskImage setResizingMode:NSImageResizingModeStretch];

[effect_view setMaskImage:maskImage];
[window_ setCornerMask:maskImage];
if (!has_frame()) {
CGFloat radius = 5.0f; // default corner radius
CGFloat dimension = 2 * radius + 1;
NSSize size = NSMakeSize(dimension, dimension);
NSImage* maskImage = [NSImage imageWithSize:size
flipped:NO
drawingHandler:^BOOL(NSRect rect) {
NSBezierPath* bezierPath = [NSBezierPath
bezierPathWithRoundedRect:rect
xRadius:radius
yRadius:radius];
[[NSColor blackColor] set];
[bezierPath fill];
return YES;
}];
[maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)];
[maskImage setResizingMode:NSImageResizingModeStretch];

[effect_view setMaskImage:maskImage];
[window_ setCornerMask:maskImage];
}

[[window_ contentView] addSubview:effect_view
positioned:NSWindowBelow
Expand Down

0 comments on commit af12533

Please sign in to comment.