Skip to content
Permalink
Browse files

8231438: [macOS] Dark mode for the desktop is not supported

Reviewed-by: prr, psadhukhan
  • Loading branch information
mrserb committed Dec 9, 2019
1 parent 1a73bae commit 3b1915a71f4ac237773fecdf79168f32ae55edda
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,25 @@ - (void)finishLaunching

JNIEnv *env = [ThreadUtilities getJNIEnv];

SEL appearanceSel = @selector(setAppearance:); // macOS 10.14+
if ([self respondsToSelector:appearanceSel]) {
NSString *appearanceProp = [PropertiesUtilities
javaSystemPropertyForKey:@"apple.awt.application.appearance"
withEnv:env];
if (![@"system" isEqual:appearanceProp]) {
// by default use light mode, because dark mode is not supported yet
NSAppearance *appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
if (appearanceProp != nil) {
NSAppearance *requested = [NSAppearance appearanceNamed:appearanceProp];
if (requested != nil) {
appearance = requested;
}
}
// [self setAppearance:appearance];
[self performSelector:appearanceSel withObject:appearance];
}
}

// Get default nib file location
// NOTE: This should learn about the current java.version. Probably best thru
// the Makefile system's -DFRAMEWORK_VERSION define. Need to be able to pass this
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
* @author Alan Snyder
* @run main FullWindowContentTest
* @requires (os.family == "mac")
*/
*/

import java.awt.AWTException;
import java.awt.Color;
@@ -120,7 +120,7 @@ private void checkTransparent() {
private void checkTranslucent() {
Color c = getTestPixel();
int delta = c.getRed() - c.getBlue();
if (delta < 50 || delta > 150) {
if (delta < 40 || delta > 150) {
throw new RuntimeException("Test failed: did not find translucent title bar color");
}
checkContent();
@@ -129,7 +129,7 @@ private void checkTranslucent() {
private void checkNormal() {
Color c = getTestPixel();
int delta = c.getRed() - c.getBlue();
if (delta < -50 || delta > 50) {
if (delta < -40 || delta > 40) {
throw new RuntimeException("Test failed: did not find normal title bar color");
}
checkContent();
@@ -202,7 +202,6 @@ public static void main(String[] args) {
try {
runSwing(() -> theTest = new FullWindowContentTest());
theTest.performTest();
;
} finally {
if (theTest != null) {
runSwing(() -> theTest.dispose());

0 comments on commit 3b1915a

Please sign in to comment.
You can’t perform that action at this time.