JRE-377 Allow dark decorations on Mac OS X (Compilation is fixed)
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index 9e15191..2f10821 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -79,6 +79,8 @@
// for client properties
public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
public static final String WINDOW_DARK_APPEARANCE = "jetbrains.awt.windowDarkAppearance";
+ public static final String WINDOW_LIGHT_APPEARANCE = "jetbrains.awt.windowLightAppearance";
+ public static final String WINDOW_AQUA_APPEARANCE = "jetbrains.awt.windowAquaAppearance";
public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
public static final String WINDOW_ALPHA = "Window.alpha";
@@ -124,6 +126,7 @@
static final int RESIZABLE = 1 << 9; // both a style bit and prop bit
static final int DARK = 1 << 28;
+ static final int LIGHT = 1 << 29;
static final int NONACTIVATING = 1 << 24;
static final int IS_DIALOG = 1 << 25;
static final int IS_MODAL = 1 << 26;
@@ -170,6 +173,9 @@
new Property<CPlatformWindow>(WINDOW_DARK_APPEARANCE) { public void applyProperty(final CPlatformWindow c, final Object value) {
c.setStyleBits(DARK, value == null ? true : Boolean.parseBoolean(value.toString()));
}},
+ new Property<CPlatformWindow>(WINDOW_LIGHT_APPEARANCE) { public void applyProperty(final CPlatformWindow c, final Object value) {
+ c.setStyleBits(LIGHT, value == null ? true : Boolean.parseBoolean(value.toString()));
+ }},
new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
}},
@@ -392,6 +398,11 @@
styleBits = SET(styleBits, DARK, Boolean.parseBoolean(prop.toString()));
}
+ prop = rootpane.getClientProperty(WINDOW_LIGHT_APPEARANCE);
+ if (prop != null) {
+ styleBits = SET(styleBits, LIGHT, Boolean.parseBoolean(prop.toString()));
+ }
+
prop = rootpane.getClientProperty(WINDOW_ZOOMABLE);
if (prop != null) {
styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m
index 3f870b1..cabd426 100644
--- a/src/macosx/native/sun/awt/AWTWindow.m
+++ b/src/macosx/native/sun/awt/AWTWindow.m
@@ -275,12 +275,19 @@
}
}
- /*if (IS(self.styleBits, DARK)) {
- [self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
- } else {
- [self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
- }*/
+/* Class* nsAppearanceClass = NSClassFromString(@"NSAppearance");
+ if (nsAppearanceClass != nil) {
+ if (IS(self.styleBits, DARK)) {
+ id darkAppearanceObject = [nsAppearanceClass appearanceNamed:@"NSAppearanceNameVibrantDark"];
+ [self.nsWindow setAppearance:darkAppearanceObject];
+ } else if (IS(self.styleBits, LIGHT)) {
+ id lightAppearanceObject = [nsAppearanceClass appearanceNamed:@"NSAppearanceNameVibrantLight"];
+ [self.nsWindow setAppearance:lightAppearanceObject];
+ } else {
+ [self.nsWindow setAppearance:nil];
+ }
+ }*/
}
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
@@ -1031,6 +1038,21 @@
}
window.styleBits = newBits;
+
+ Class* nsAppearanceClass = NSClassFromString(@"NSAppearance");
+
+ if (nsAppearanceClass != nil) {
+ if (IS(window.styleBits, DARK)) {
+ id darkAppearanceObject = [nsAppearanceClass appearanceNamed:@"NSAppearanceNameVibrantDark"];
+ [nsWindow setAppearance:darkAppearanceObject];
+ } else if (IS(window.styleBits, LIGHT)) {
+ id lightAppearanceObject = [nsAppearanceClass appearanceNamed:@"NSAppearanceNameVibrantLight"];
+ [nsWindow setAppearance:lightAppearanceObject];
+ } else {
+ [nsWindow setAppearance:nil];
+ }
+ }
+
}];
JNF_COCOA_EXIT(env);