--- old/src/java.desktop/share/classes/sun/font/FontUtilities.java 2018-11-25 21:42:03 +0000 +++ new/src/java.desktop/share/classes/sun/font/FontUtilities.java 2018-11-25 21:42:03 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -50,6 +50,8 @@ public static boolean isMacOSX; + public static boolean isAIX; + public static boolean useJDKScaler; public static boolean isWindows; @@ -72,6 +74,8 @@ isMacOSX = osName.contains("OS X"); // TODO: MacOSX + isAIX = osName.startsWith("AIX"); + /* If set to "jdk", use the JDK's scaler rather than * the platform one. This may be a no-op on platforms where * JDK has been configured so that it always relies on the --- old/src/java.desktop/unix/classes/sun/awt/X11/MotifColorUtilities.java 2018-11-25 21:42:04 +0000 +++ new/src/java.desktop/unix/classes/sun/awt/X11/MotifColorUtilities.java 2018-11-25 21:42:04 +0000 @@ -29,6 +29,7 @@ import java.io.*; import sun.security.action.GetPropertyAction; import java.security.AccessController; +import sun.font.FontUtilities; /** * @@ -434,6 +435,31 @@ // System.out.println("color["+i+"]="+Integer.toHexString(colors[i]) + "r = " +r + "g="+g+"b="+b); } + int numOfColor = 4; + if (FontUtilities.isAIX) { + numOfColor = 8; + } + int idx = resourceString.indexOf("ColorUse:"); + if (idx > -1) { + while ( (idx < len) && (resourceString.charAt(idx) != ':')) idx++; + idx++; // skip : + if (resourceString.charAt(idx) == '\t') idx++; // skip \t + String colorUse = resourceString.substring(idx,resourceString.indexOf("\n",idx)); + if ("HIGH_COLOR".equalsIgnoreCase(colorUse)) { + numOfColor = 8; + } else if ("MEDIUM_COLOR".equalsIgnoreCase(colorUse)) { + numOfColor = 4; + } + } + + if (4 == numOfColor) + loadSystemColorsForCDE4(systemColors, colors); + else + loadSystemColorsForCDE8(systemColors, colors); + } + + private static void loadSystemColorsForCDE4(int[] systemColors, int[] colors) throws Exception { + int r,g,b; systemColors[SystemColor.ACTIVE_CAPTION] = colors[0]; systemColors[SystemColor.ACTIVE_CAPTION_BORDER] = colors[0]; @@ -496,6 +522,84 @@ } + private static void loadSystemColorsForCDE8(int[] systemColors, int[] colors) throws Exception { + int r,g,b; + systemColors[SystemColor.ACTIVE_CAPTION] = colors[0]; + systemColors[SystemColor.ACTIVE_CAPTION_BORDER] = colors[0]; + + systemColors[SystemColor.INACTIVE_CAPTION] = colors[1]; + systemColors[SystemColor.INACTIVE_CAPTION_BORDER] = colors[1]; + + systemColors[SystemColor.WINDOW] = colors[4]; + + systemColors[SystemColor.MENU] = colors[5]; + + systemColors[SystemColor.TEXT] = colors[3]; + systemColors[SystemColor.TEXT_HIGHLIGHT_TEXT] = colors[3]; + + systemColors[SystemColor.SCROLLBAR] = colors[4]; + systemColors[SystemColor.CONTROL] = colors[4]; + systemColors[SystemColor.INFO] = colors[4]; + + int activeFore; + int inactiveFore; + int textFore; + + + r = (colors[0] & 0x00FF0000) >> 16; + g = (colors[0] & 0x0000FF00) >> 8; + b = (colors[0] & 0x000000FF); + + activeFore = MotifColorUtilities.calculateForegroundFromBackground(r,g,b); + + r = (colors[1] & 0x00FF0000) >> 16; + g = (colors[1] & 0x0000FF00) >> 8; + b = (colors[1] & 0x000000FF); + + inactiveFore = MotifColorUtilities.calculateForegroundFromBackground(r,g,b); + + r = (colors[3] & 0x00FF0000) >> 16; + g = (colors[3] & 0x0000FF00) >> 8; + b = (colors[3] & 0x000000FF); + + textFore = MotifColorUtilities.calculateForegroundFromBackground(r,g,b); + + r = (colors[4] & 0x00FF0000) >> 16; + g = (colors[4] & 0x0000FF00) >> 8; + b = (colors[4] & 0x000000FF); + + int windowFore = MotifColorUtilities.calculateForegroundFromBackground(r,g,b); + + int top_shadow = MotifColorUtilities.calculateTopShadowFromBackground(r,g,b); + int bottom_shadow = MotifColorUtilities.calculateBottomShadowFromBackground(r,g,b); + + + r = (colors[5] & 0x00FF0000) >> 16; + g = (colors[5] & 0x0000FF00) >> 8; + b = (colors[5] & 0x000000FF); + + int menuFore = MotifColorUtilities.calculateForegroundFromBackground(r,g,b); + + systemColors[SystemColor.ACTIVE_CAPTION_TEXT] = activeFore; + systemColors[SystemColor.INACTIVE_CAPTION_TEXT] = inactiveFore; + systemColors[SystemColor.WINDOW_BORDER] = MotifColorUtilities.BLACK; + systemColors[SystemColor.WINDOW_TEXT] = windowFore; + systemColors[SystemColor.MENU_TEXT] = menuFore; + systemColors[SystemColor.TEXT_TEXT] = textFore; + systemColors[SystemColor.TEXT_HIGHLIGHT] = textFore; + systemColors[SystemColor.CONTROL_TEXT] = windowFore; + Color tmp = new Color(top_shadow); + systemColors[SystemColor.CONTROL_HIGHLIGHT] = top_shadow; + systemColors[SystemColor.CONTROL_LT_HIGHLIGHT] = tmp.brighter().getRGB(); + + tmp = new Color(bottom_shadow); + systemColors[SystemColor.CONTROL_SHADOW] = bottom_shadow; + systemColors[SystemColor.CONTROL_DK_SHADOW] = tmp.darker().getRGB(); + + systemColors[SystemColor.INFO_TEXT] = windowFore; + + } + static void loadMotifDefaultColors(int[] systemColors) { //fix for 5092883. WINDOW should be light gray and TEXT should be WHITE to look similar to Motif systemColors[SystemColor.WINDOW] = MotifColorUtilities.MOTIF_WINDOW_COLOR; --- old/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2018-11-25 21:42:05 +0000 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2018-11-25 21:42:05 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -38,6 +38,7 @@ import sun.awt.AWTAccessor; import sun.awt.SunToolkit; +import sun.font.FontUtilities; abstract class XDecoratedPeer extends XWindowPeer { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XDecoratedPeer"); @@ -808,6 +809,12 @@ updateChildrenSizes(); Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top); + if (XWM.isMotif()) { + if (!isFocusableWindow() && FontUtilities.isAIX) { + Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target); + newLocation = targetBounds.getLocation(); + } + } WindowDimensions newDimensions = new WindowDimensions(newLocation, new Dimension(scaleDown(xe.get_width()), --- old/src/java.desktop/unix/classes/sun/awt/X11/XWM.java 2018-11-25 21:42:06 +0000 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XWM.java 2018-11-25 21:42:06 +0000 @@ -41,6 +41,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import sun.util.logging.PlatformLogger; +import sun.font.FontUtilities; /** @@ -530,6 +531,13 @@ return false; } return true; + } else if (FontUtilities.isAIX) { + XQueryTree qt = new XQueryTree(wmwin); + try { + if (qt.execute() > 0) return true; + } finally { + qt.dispose(); + } } else { // No DT_WORKSPACE, however in our tests MWM sometimes can be without desktop - // and that is still MWM. So simply check for the validity of this window --- old/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java 2018-11-25 21:42:07 +0000 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java 2018-11-25 21:42:07 +0000 @@ -66,6 +66,7 @@ import sun.awt.X11GraphicsEnvironment; import sun.java2d.pipe.Region; import sun.util.logging.PlatformLogger; +import sun.font.FontUtilities; class XWindowPeer extends XPanelPeer implements WindowPeer, DisplayChangedListener { @@ -2023,6 +2024,23 @@ try { this.visible = visible; if (visible) { + if (FontUtilities.isAIX) { + /* On Motif Window Manager, non-focusable window should not set WM_TAKE_FOCUS */ + XAtomList currentWMProtocols = wm_protocols.getAtomListPropertyList(this); + if (isFocusableWindow()) { + if (!currentWMProtocols.contains(wm_take_focus)) { + currentWMProtocols.add(wm_take_focus); + wm_protocols.setAtomListProperty(this, currentWMProtocols); + } + } else { + if (XWM.isMotif()) { + if (currentWMProtocols.contains(wm_take_focus)) { + currentWMProtocols.remove(wm_take_focus); + wm_protocols.setAtomListProperty(this, currentWMProtocols); + } + } + } + } applyWindowType(); XlibWrapper.XMapRaised(XToolkit.getDisplay(), getWindow()); } else {