Skip to content

feat: add roundedCorners option for BrowserWindow - #27572

Merged
codebytere merged 3 commits into
masterfrom
rounded-corner
Feb 9, 2021
Merged

codebytere merged 3 commits into
masterfrom
rounded-corner

Conversation

@zcbenz

@zcbenz zcbenz commented Feb 1, 2021 •

Copy link
Copy Markdown
Contributor

Description of Change

Add an option to remove rounded corners of frameless windows on macOS, close #414.

Checklist

Release Notes

Notes: Add roundedCorners option for BrowserWindow.

@zcbenz zcbenz added the semver/minor backwards-compatible functionality label Feb 1, 2021

@samuelmaddock samuelmaddock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BrowserWindows with vibrancy options seem to apply their own corner radius size. Would this new option be compatible with this behavior?

// Make frameless Vibrant windows have rounded corners.
if (!has_frame() && !is_modal()) {
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)];

Would it be possible to instead provide a cornerRadius option where the amount could be specified? If it were 0, rounded corners could be disabled. I'm not too familiar with macOS development to know whether this is supported or not.

Comment thread docs/api/browser-window.md Resolved
@zcbenz

zcbenz commented Feb 2, 2021

Copy link
Copy Markdown
Contributor Author

BrowserWindows with vibrancy options seem to apply their own corner radius size. Would this new option be compatible with this behavior?

Thanks for noticing it, I have fixed the code to work with vibrancy views.

Would it be possible to instead provide a cornerRadius option where the amount could be specified? If it were 0, rounded corners could be disabled. I'm not too familiar with macOS development to know whether this is supported or not.

No, the referenced code is used to set corner radius of the vibrancy view so it would not cover the window's rounded corners, macOS does not provide a way to change the corner radius of the window.

wouldn't roundedCorners be a better name?

Yeah it sounds a better name, I have changed the option's name.

@zcbenz zcbenz changed the title feat: add roundedCorner option for BrowserWindow feat: add roundedCorners option for BrowserWindow Feb 2, 2021
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Feb 8, 2021
@codebytere
codebytere merged commit af4a050 into master Feb 9, 2021
@release-clerk

release-clerk Bot commented Feb 9, 2021

Copy link
Copy Markdown

Release Notes Persisted

Add roundedCorners option for BrowserWindow.

@codebytere
codebytere deleted the rounded-corner branch February 9, 2021 16:38
@ldenoue

ldenoue commented Nov 15, 2021 •

Copy link
Copy Markdown

I noticed that when using this property roundedCorners: true when creating a BrowserWindow with a Tray, my app and windows never close.

@giacomocerquone

Copy link
Copy Markdown

I noticed that when using this property roundedCorners: true when creating a BrowserWindow with a Tray, my app and windows never close.

yes, a repro has been created and the issue is tracked here: #28686

I tried to have a look at the code, but honestly, I'm no obj-c macOS dev sadly, and couldn't figure out much.s
@zcbenz would be nice to have some hints on what to investigate upon.

@Alecyrus

Copy link
Copy Markdown
Contributor

@zcbenz Is it possible that this option is available for windows 11?

@zcbenz

zcbenz commented Nov 21, 2022

Copy link
Copy Markdown
Contributor Author

@zcbenz Is it possible that this option is available for windows 11?

I can't find any Windows API for it. There is also an article on this topic: https://valinet.ro/2022/01/21/Disable-the-rounded-corners-in-Windows-11.html, but it does not imply any windows style to disable the rounded corner.

@renegadevi

renegadevi commented Dec 21, 2022 •

Copy link
Copy Markdown

@zcbenz Is it possible that this option is available for windows 11?

I need a solution for this as well. Windowed mode is now "broken" in windows 11 because of rounded corners which is not always the intended use when you want a on purpose a dimensioned canvas. This issue is gone when pressing F11 to go into fullscreen mode or when using kioskmode, which is not ideal either for all use cases. At the same time, the full canvas is still recognised as a square with all the pixels even tho the pixels are like masked above.

Windows 10:

windows_10

Windows 11: (corners being cut off)
windows_11

As you can also see, even tho both is set to setPosition(0, 0), windows 11 starts at (1,1) causing a little padding issue. To prevent this I have to subtract with -1

@renegadevi

renegadevi commented Dec 21, 2022 •

Copy link
Copy Markdown

I found one workaround. By using thickFrame: false it fixes both the rounded corners and the position being 0,0 again.

However, this in turn causes the F11 key only to fullscreen, I cannot longer back out from fullscreen with F11, however I can still resize it from the mouse in the bottom corner.

@Alecyrus @zcbenz

@Pratiyankkumar

Copy link
Copy Markdown

I can't use roundedCorners: true in windows .(Is it just for macOS??)

@wangrongding

Copy link
Copy Markdown

Nice! After searching for a while, I finally found it!👏👏👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/approved ✅ semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Border Radius From Frameless Window On Mac

10 participants