Skip to content

Commit

Permalink
macOS native rounded borders: (PR #772)
Browse files Browse the repository at this point in the history
- removed opacity from contentView.layer
- catch and log exceptions
  • Loading branch information
DevCharly committed Jan 21, 2025
1 parent 2ef87dc commit 5e78b21
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Binary file not shown.
Binary file not shown.
16 changes: 11 additions & 5 deletions flatlaf-natives/flatlaf-natives-macos/src/main/headers/JNIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@
#endif


#define JNI_COCOA_TRY() \
@try {

#define JNI_COCOA_CATCH() \
} @catch( NSException *ex ) { \
NSLog( @"Exception: %@\nReason: %@\nUser Info: %@\nStack: %@", \
[ex name], [ex reason], [ex userInfo], [ex callStackSymbols] ); \
}

#define JNI_COCOA_ENTER() \
@autoreleasepool { \
@try {
JNI_COCOA_TRY()

#define JNI_COCOA_EXIT() \
} @catch( NSException *ex ) { \
NSLog( @"Exception: %@\nReason: %@\nUser Info: %@\nStack: %@", \
[ex name], [ex reason], [ex userInfo], [ex callStackSymbols] ); \
} \
JNI_COCOA_CATCH() \
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ @implementation WindowData
return FALSE;

[FlatJNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
JNI_COCOA_TRY()

nsWindow.hasShadow = YES;
nsWindow.contentView.wantsLayer = YES;
nsWindow.contentView.layer.cornerRadius = radius;
nsWindow.contentView.layer.masksToBounds = YES;
nsWindow.contentView.layer.opaque = NO;

nsWindow.contentView.layer.borderWidth = borderWidth;
if( borderWidth > 0 ) {
Expand All @@ -120,6 +123,8 @@ @implementation WindowData

[nsWindow.contentView.layer removeAllAnimations];
[nsWindow invalidateShadow];

JNI_COCOA_CATCH()
}];

return TRUE;
Expand Down Expand Up @@ -157,6 +162,8 @@ @implementation WindowData
WindowData* windowData = getWindowData( nsWindow, true );

[FlatJNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
JNI_COCOA_TRY()

// NSLog( @"\n%@\n\n", [nsWindow.contentView.superview _subtreeDescription] );

// add/remove toolbar
Expand Down Expand Up @@ -235,6 +242,8 @@ @implementation WindowData
windowData.didExitFullScreenObserver = nil;
}
}

JNI_COCOA_CATCH()
}];

return TRUE;
Expand Down

0 comments on commit 5e78b21

Please sign in to comment.