aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lobas <alexander-lobas@users.noreply.github.com>2023-01-20 22:15:39 +0300
committerGitHub <noreply@github.com>2023-01-20 22:15:39 +0300
commitba490e39290cff1755c49d49917fc309ae514427 (patch)
treed37aab4c699b1e1e77075ab47608620fa92c7c85
parent98d182d08d1de569046a9476b94e782082f38df1 (diff)
parent2106e4151230b72a6ff4ef6e5e4f0dcedf4a2b5e (diff)
downloadJetBrainsRuntime-ba490e39290cff1755c49d49917fc309ae514427.tar.gz
Merge pull request #207 from alexander-lobas/jbr17jbr-release-17.0.6b779.1jb17.0.6-b779.1jb17.0.6-b779
JBR-5197 Window control buttons are not visible in full-screen mode in dark themes when IDE window is focused
-rw-r--r--src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h1
-rw-r--r--src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m64
2 files changed, 60 insertions, 5 deletions
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h
index 3035fea340e..bb86c9f3399 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.h
@@ -119,6 +119,7 @@
@end
@interface AWTButtonsView : NSView
+- (CGFloat)getThemeAlphaValue:(NSWindow *)window;
@end
#endif _AWTWINDOW_H
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
index 47c56556dd3..a366806cb84 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
@@ -38,6 +38,7 @@
#import "ThreadUtilities.h"
#import "NSApplicationAWT.h"
#import "JNIUtilities.h"
+#import "PropertiesUtilities.h"
#define MASK(KEY) \
(sun_lwawt_macosx_CPlatformWindow_ ## KEY)
@@ -65,6 +66,7 @@ static jclass jc_CPlatformWindow = NULL;
@interface NSWindow (Private)
- (void)_setTabBarAccessoryViewController:(id)controller;
+- (int)getJavaWindowBackgroundColor;
@end
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
@@ -362,6 +364,42 @@ AWT_NS_WINDOW_IMPLEMENTATION
return NO;
}
+- (int)getJavaWindowBackgroundColor {
+ AWT_ASSERT_APPKIT_THREAD;
+
+ JNIEnv *env = [ThreadUtilities getJNIEnv];
+ jobject platformWindow = (*env)->NewLocalRef(env, ((AWTWindow *)self.delegate).javaPlatformWindow);
+ if (platformWindow == NULL) {
+ return -1;
+ }
+
+ GET_CPLATFORM_WINDOW_CLASS_RETURN(-1);
+ DECLARE_FIELD_RETURN(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;", -1);
+ jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target);
+
+ int rgb = -1;
+
+ if (awtWindow != NULL) {
+ DECLARE_CLASS_RETURN(jc_Component, "java/awt/Component", -1);
+ DECLARE_METHOD_RETURN(jm_getBackground, jc_Component, "getBackground", "()Ljava/awt/Color;", -1);
+ jobject jColor = (*env)->CallObjectMethod(env, awtWindow, jm_getBackground);
+
+ if (jColor != NULL) {
+ DECLARE_CLASS_RETURN(jc_Color, "java/awt/Color", -1);
+ DECLARE_METHOD_RETURN(jm_getRGB, jc_Color, "getRGB", "()I", -1);
+
+ rgb = (*env)->CallIntMethod(env, jColor, jm_getRGB);
+ (*env)->DeleteLocalRef(env, jColor);
+ }
+
+ (*env)->DeleteLocalRef(env, awtWindow);
+ }
+
+ (*env)->DeleteLocalRef(env, platformWindow);
+
+ return rgb;
+}
+
@end
@implementation AWTWindow_Panel
AWT_NS_WINDOW_IMPLEMENTATION
@@ -1309,7 +1347,12 @@ AWT_ASSERT_APPKIT_THREAD;
[self fullScreenTransitionFinished];
if ([self isTransparentTitleBarEnabled]) {
- [self setWindowFullScreeControls];
+ JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
+ NSString *newFullScreeControls = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.newFullScreeControls"
+ withEnv:env];
+ if ([@"true" isCaseInsensitiveLike:newFullScreeControls]) {
+ [self setWindowFullScreeControls];
+ }
}
JNIEnv *env = [ThreadUtilities getJNIEnv];
@@ -1637,23 +1680,24 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
owner:_fullScreenButtons userInfo:nil]];
NSUInteger masks = [self.nsWindow styleMask];
+ CGFloat alphaValue = [(AWTButtonsView *)_fullScreenButtons getThemeAlphaValue:self.nsWindow];
NSButton *closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:masks];
[closeButton setFrame:closeButtonRect];
[closeButton setEnabled:NO];
- [closeButton setAlphaValue:0.1];
+ [closeButton setAlphaValue:alphaValue];
[_fullScreenButtons addSubview:closeButton];
NSButton *miniaturizeButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:masks];
[miniaturizeButton setFrame:miniaturizeButtonRect];
[miniaturizeButton setEnabled:NO];
- [miniaturizeButton setAlphaValue:0.1];
+ [miniaturizeButton setAlphaValue:alphaValue];
[_fullScreenButtons addSubview:miniaturizeButton];
NSButton *zoomButton = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:masks];
[zoomButton setFrame:zoomButtonRect];
[zoomButton setEnabled:NO];
- [zoomButton setAlphaValue:0.1];
+ [zoomButton setAlphaValue:alphaValue];
[_fullScreenButtons addSubview:zoomButton];
[parent addSubview:_fullScreenButtons];
@@ -1805,6 +1849,7 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
- (void)updateButtons:(BOOL) flag {
if (self.subviews.count == 3) {
[self updateButton:0 flag:flag]; // close
+ [self updateButton:1 flag:NO]; // miniaturize
[self updateButton:2 flag:flag]; // zoom
}
}
@@ -1812,10 +1857,19 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
- (void)updateButton: (int)index flag:(BOOL) flag {
NSButton *button = (NSButton*)self.subviews[index];
[button setEnabled:flag];
- [button setAlphaValue:(flag ? 1.0 : 0.1)];
+ [button setAlphaValue:(flag ? 1.0 : [self getThemeAlphaValue:self.window])];
[button setHighlighted:flag];
}
+- (CGFloat)getThemeAlphaValue:(NSWindow *)window {
+ int rgb = [window getJavaWindowBackgroundColor];
+ int r = (rgb >> 16) & 0xff;
+ int g = (rgb >> 8) & 0xff;
+ int b = (rgb >> 0) & 0xff;
+
+ return r > 128 && g > 128 && b > 128 ? 0.1 : 0.7;
+}
+
@end
/*