Skip to content

Commit c577324

Browse files
bourgesljbrbot
authored andcommitted
JBR-9375 macOS: Right-click context menu shows blurry animation when opening
Disable NSWindow animationBehavior (=NSWindowAnimationBehaviorNone) by default except if the system property 'apple.awt.window.animation' = true + Fixed J2dRlsTraceLn
1 parent 2f6b82c commit c577324

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ BOOL isColorMatchingEnabled() {
7575
return (BOOL)colorMatchingEnabled;
7676
}
7777

78+
BOOL isWindowAnimationEnabled() {
79+
static int windowAnimationEnabled = -1;
80+
if (windowAnimationEnabled == -1) {
81+
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
82+
if (env == NULL) return NO;
83+
NSString* windowAnimationEnabledProp = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.window.animation"
84+
withEnv:env];
85+
windowAnimationEnabled = [@"true" isCaseInsensitiveLike:windowAnimationEnabledProp] ? YES : NO;
86+
J2dRlsTraceLn(J2D_TRACE_INFO, "AWTWindow_windowAnimationEnabled: %d", windowAnimationEnabled);
87+
}
88+
return (BOOL)windowAnimationEnabled;
89+
}
90+
7891
@interface NSTitlebarAccessoryViewController (Private)
7992
- (void)_setHidden:(BOOL)h animated:(BOOL)a;
8093
@end
@@ -605,6 +618,10 @@ - (id) initWithPlatformWindow:(jobject)platformWindow
605618
if (self.nsWindow == nil) return nil; // no hope either
606619
[self.nsWindow release]; // the property retains the object already
607620

621+
if (!isWindowAnimationEnabled()
622+
&& (self.nsWindow.animationBehavior != NSWindowAnimationBehaviorNone)) {
623+
self.nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
624+
}
608625
if (isColorMatchingEnabled()) {
609626
// Supported by both OpenGL & Metal pipelines
610627
// Tell the system we have an sRGB backing store
@@ -3008,8 +3025,6 @@ void enableFullScreenSpecial(NSWindow *nsWindow) {
30083025

30093026
NSWindow *w = (NSWindow *)jlong_to_ptr(windowPtr);
30103027
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
3011-
w.hasShadow = YES;
3012-
w.contentView.wantsLayer = YES;
30133028
w.contentView.layer.cornerRadius = radius;
30143029
w.contentView.layer.masksToBounds = YES;
30153030
w.contentView.layer.opaque = NO;
@@ -3024,11 +3039,11 @@ void enableFullScreenSpecial(NSWindow *nsWindow) {
30243039
w.contentView.layer.borderWidth = borderWidth;
30253040
w.contentView.layer.borderColor = color.CGColor;
30263041
}
3042+
w.contentView.wantsLayer = YES;
30273043

30283044
w.backgroundColor = NSColor.clearColor;
30293045
w.opaque = NO;
3030-
// remove corner radius animation
3031-
[w.contentView.layer removeAllAnimations];
3046+
w.hasShadow = YES;
30323047
[w invalidateShadow];
30333048
}];
30343049

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ - (id) initWithJavaLayer:(jobject)layer usePerfCounters:(jboolean)perfCountersEn
129129
[NSNull null], @"anchorPoint",
130130
[NSNull null], @"bounds",
131131
[NSNull null], @"contents",
132+
[NSNull null], @"cornerRadius",
132133
[NSNull null], @"contentsScale",
133134
[NSNull null], @"onOrderIn",
134135
[NSNull null], @"onOrderOut",

src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLLayer.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ - (id) initWithJavaLayer:(jobject)layer;
6363
[NSNull null], @"anchorPoint",
6464
[NSNull null], @"bounds",
6565
[NSNull null], @"contents",
66+
[NSNull null], @"cornerRadius",
6667
[NSNull null], @"contentsScale",
6768
[NSNull null], @"onOrderIn",
6869
[NSNull null], @"onOrderOut",

0 commit comments

Comments
 (0)