8201598: Fix for 8181910: Support dark title bars on macOS broke the MacOS build
authorsveerabhadra
Wed, 18 Apr 2018 10:43:43 +0530
changeset 49994 0e9be7add10a
parent 49993 3d2aeea95d8c
child 49995 6f595ec05539
8201598: Fix for 8181910: Support dark title bars on macOS broke the MacOS build Reviewed-by: prr, serb
src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
test/jdk/javax/swing/JFrame/DarkTitleBar/DarkTitleBar.java
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Apr 17 18:18:26 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Wed Apr 18 10:43:43 2018 +0530
@@ -101,7 +101,6 @@
     // for client properties
     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
-    public static final String WINDOW_DARK_APPEARANCE = "apple.awt.windowDarkAppearance";
 
     public static final String WINDOW_ALPHA = "Window.alpha";
     public static final String WINDOW_SHADOW = "Window.shadow";
@@ -149,7 +148,6 @@
     static final int IS_DIALOG = 1 << 25;
     static final int IS_MODAL = 1 << 26;
     static final int IS_POPUP = 1 << 27;
-    static final int DARK_TITLE_BAR = 1 << 28;
 
     static final int _STYLE_PROP_BITMASK = DECORATED | TEXTURED | UNIFIED | UTILITY | HUD | SHEET | CLOSEABLE | MINIMIZABLE | RESIZABLE;
 
@@ -232,10 +230,7 @@
 
             final String filename = ((java.io.File)value).getAbsolutePath();
             c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename));
-        }},
-        new Property<CPlatformWindow>(WINDOW_DARK_APPEARANCE) { public void applyProperty(final CPlatformWindow c, final Object value) {
-            c.setStyleBits(DARK_TITLE_BAR, value == null ? true : Boolean.parseBoolean(value.toString()));
-        }},
+        }}
     }) {
         @SuppressWarnings("deprecation")
         public CPlatformWindow convertJComponentToTarget(final JRootPane p) {
@@ -473,11 +468,6 @@
             if (prop != null) {
                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
             }
-
-            prop = rootpane.getClientProperty(WINDOW_DARK_APPEARANCE);
-            if (prop != null) {
-               styleBits = SET(styleBits, DARK_TITLE_BAR, Boolean.parseBoolean(prop.toString()));
-            }
         }
 
         if (isDialog) {
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Tue Apr 17 18:18:26 2018 -0700
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Apr 18 10:43:43 2018 +0530
@@ -262,13 +262,7 @@
         } else {
             [self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
         }
-    }
-
-    if (IS(self.styleBits, DARK_TITLE_BAR)) {
-        [self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
-    } else {
-        [self.nsWindow setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]];
-    }    
+    } 
 }
 
 - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
--- a/test/jdk/javax/swing/JFrame/DarkTitleBar/DarkTitleBar.java	Tue Apr 17 18:18:26 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.awt.Robot;
-import java.awt.Color;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-/**
- * @test
- * @key headful
- * @bug 8181910
- * @requires (os.family == "mac")
- * @summary [macos] Support dark title bars on macOS
- * @run main DarkTitleBar
- */
-
-public final class DarkTitleBar {
-    private static BufferedImage image = null;
-    private static Rectangle bounds;
-    private static JFrame frame;
-    private static Robot robot;
-
-    public static void main(final String[] args) throws Exception {
-        robot = new Robot();
-        robot.setAutoDelay(50);
-
-        // Capture and compare pixel color
-        testFrame();
-    }
-
-    private static void testFrame() throws Exception {
-        createUI();
-        image = robot.createScreenCapture(bounds);
-        SwingUtilities.invokeAndWait(frame::dispose);
-        robot.waitForIdle();
-
-        Color titleColor = new Color(image.getRGB(100, 5), true);
-        if(titleColor.getRed() > 50 || titleColor.getGreen() > 50 || titleColor.getBlue() > 50) {
-            throw new RuntimeException("Test failed: Title bar is not of dark colored - " + titleColor);
-        }
-    }
-
-    private static void createUI() throws Exception {
-        SwingUtilities.invokeAndWait(() -> {
-            frame = new JFrame();
-            frame.setUndecorated(false);
-            frame.setSize(400, 400);
-            frame.setLocationRelativeTo(null);
-            frame.getRootPane().putClientProperty("apple.awt.windowDarkAppearance", true);
-            frame.setVisible(true);
-        });
-
-        robot.waitForIdle();
-        SwingUtilities.invokeAndWait(() -> {
-            bounds = frame.getBounds();
-        });
-        robot.waitForIdle();
-
-        robot.mouseMove(frame.getX() + 100, frame.getY() + 5); // pixel at which color will be captured
-        robot.waitForIdle();
-    }
-}