From 117713bd928ee0398ea33fad44d06f032413db4a Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Wed, 27 Jul 2016 01:26:47 +0000 Subject: [PATCH 01/80] 8159488: Deprivilege java.xml.crypto Moved java.xml.crypto module from boot modules to platform modules Reviewed-by: mullan --- make/common/Modules.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index bd4747891f8..fa68288c226 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -58,7 +58,6 @@ BOOT_MODULES += \ java.security.jgss \ java.security.sasl \ java.xml \ - java.xml.crypto \ jdk.httpserver \ jdk.management \ jdk.net \ @@ -106,6 +105,7 @@ PLATFORM_MODULES += \ java.smartcardio \ java.sql \ java.sql.rowset \ + java.xml.crypto \ jdk.accessibility \ jdk.charsets \ jdk.crypto.ec \ From eb5d47885168209b68acb708db661f69b079eb5c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 28 Jul 2016 16:08:13 +0000 Subject: [PATCH 02/80] Added tag jdk-9+129 for changeset ed24939e8679 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index c2c23ebab23..918c4e57478 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -371,3 +371,4 @@ f80c841ae2545eaf9acd2724bccc305d98cefbe2 jdk-9+124 3a58466296d36944454756ef01e7513ac5e14a16 jdk-9+126 8fa686245bd2a072ece3392743460030f0854520 jdk-9+127 b30ae794d974d7dd3eb4e84203f70021823fa6c6 jdk-9+128 +f5902d3841b82cac6e7716a20c24e8e916fb14a8 jdk-9+129 From 19fa760d9c578de7aabfccf1a222cc142aa2df2f Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Mon, 4 Apr 2016 18:35:51 +0200 Subject: [PATCH 03/80] 8149519: Set java.specification.version to the MAJOR java version Reviewed-by: alanb, dholmes, iris --- common/autoconf/spec.gmk.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 26705337a95..0efabd42a15 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -175,8 +175,8 @@ VERSION_NUMBER_FOUR_POSITIONS := @VERSION_NUMBER_FOUR_POSITIONS@ VERSION_STRING := @VERSION_STRING@ # The short version string, without trailing zeroes and just PRE, if present. VERSION_SHORT := @VERSION_SHORT@ -# The Java specification version. It should be equal to version number. -VERSION_SPECIFICATION := @VERSION_NUMBER@ +# The Java specification version. It usually equals to the major version number. +VERSION_SPECIFICATION := @VERSION_MAJOR@ # A GA version is defined by the PRE string being empty. Rather than testing for # that, this variable defines it with true/false. VERSION_IS_GA := @VERSION_IS_GA@ From 6132b8f774d9fa0da0389f57f273edb0a654dbbd Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Tue, 5 Jul 2016 16:20:00 +0530 Subject: [PATCH 04/80] 7156316: [macosx] Ctrl+Space does generate Unknown keychar Reviewed-by: alexsch, aniyogi --- .../classes/sun/lwawt/macosx/CPlatformResponder.java | 8 +++++++- .../macosx/classes/sun/lwawt/macosx/NSEvent.java | 2 +- .../macosx/native/libawt_lwawt/awt/AWTEvent.m | 11 ++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index 67896a59521..0283b05e5d8 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -135,6 +135,7 @@ final class CPlatformResponder { int jkeyCode = KeyEvent.VK_UNDEFINED; int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN; boolean postsTyped = false; + boolean spaceKeyTyped = false; char testChar = KeyEvent.CHAR_UNDEFINED; boolean isDeadChar = (chars!= null && chars.length() == 0); @@ -151,6 +152,11 @@ final class CPlatformResponder { } else { if (chars != null && chars.length() > 0) { testChar = chars.charAt(0); + + //Check if String chars contains SPACE character. + if (chars.trim().isEmpty()) { + spaceKeyTyped = true; + } } char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ? @@ -187,7 +193,7 @@ final class CPlatformResponder { NSEvent.nsToJavaEventType(eventType); } - char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags); + char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags, spaceKeyTyped); // Some keys may generate a KEY_TYPED, but we can't determine // what that character is. That's likely a bug, but for now we // just check for CHAR_UNDEFINED. diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java index 290e52965a3..d39f559be22 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java @@ -254,7 +254,7 @@ final class NSEvent { * There is a small number of NS characters that need to be converted * into other characters before we pass them to AWT. */ - static native char nsToJavaChar(char nsChar, int modifierFlags); + static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped); static boolean isPopupTrigger(int jmodifiers) { final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0); diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index 1c2e14d931c..69fe7a90406 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -349,7 +349,7 @@ const charTable[] = { {0, 0, 0} }; -unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers) +unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers, BOOL spaceKeyTyped) { const struct _char *cur; // Mask off just the keyboard modifiers from the event modifier mask. @@ -382,6 +382,11 @@ unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers) return java_awt_event_KeyEvent_CHAR_UNDEFINED; } + // nsChar receives value 0 when SPACE key is typed. + if (nsChar == 0 && spaceKeyTyped == YES) { + return java_awt_event_KeyEvent_VK_SPACE; + } + // otherwise return character unchanged return nsChar; } @@ -757,13 +762,13 @@ JNF_COCOA_EXIT(env); */ JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_NSEvent_nsToJavaChar -(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags) +(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags, jboolean spaceKeyTyped) { jchar javaChar = 0; JNF_COCOA_ENTER(env); - javaChar = NsCharToJavaChar(nsChar, modifierFlags); + javaChar = NsCharToJavaChar(nsChar, modifierFlags, spaceKeyTyped); JNF_COCOA_EXIT(env); From aa157d7826ec310e4b58cb564b9794a5a5d22cb5 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 5 Jul 2016 19:40:26 +0300 Subject: [PATCH 05/80] 8156212: Typo in javadoc of java.awt.Taskbar, setIconBadge spec Reviewed-by: alexsch, ssadetsky --- jdk/src/java.desktop/share/classes/java/awt/Taskbar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java index 64bb2553459..a0660ac00d5 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java @@ -356,7 +356,7 @@ public class Taskbar { * * Some platforms do not support string values and accept only integer * values. In this case, pass an integer represented as a string as parameter. - * This can be tested by {@code Feature.ICON_BADGE_STRING} and + * This can be tested by {@code Feature.ICON_BADGE_TEXT} and * {@code Feature.ICON_BADGE_NUMBER}. * * Passing {@code null} as parameter hides the badge. From 95dc3d009d2200328e083cc46dbfe62cbf3d9be6 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 5 Jul 2016 19:41:47 +0300 Subject: [PATCH 06/80] 8155515: Desktop.moveToTrash() javadoc issue Reviewed-by: alexsch, ssadetsky --- jdk/src/java.desktop/share/classes/java/awt/Desktop.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java index 2cb38519ed5..f738fd78203 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Desktop.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Desktop.java @@ -1013,8 +1013,8 @@ public class Desktop { * @param file the file * @return returns true if successfully moved the file to the trash. * @throws SecurityException If a security manager exists and its - * {@link SecurityManager#checkWrite(java.lang.String)} method - * denies write access to the file + * {@link SecurityManager#checkDelete(java.lang.String)} method + * denies deletion of the file * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#MOVE_TO_TRASH} action * @throws NullPointerException if {@code file} is {@code null} From a2168558c1a124ad36268c67a5073fa9183718a0 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Wed, 6 Jul 2016 21:07:35 +0530 Subject: [PATCH 07/80] 8160764: [TEST_BUG] java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java Reviewed-by: alexsch, ssadetsky --- .../TextAreaScrolling/TextAreaScrolling.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java b/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java index d6b98a6fcd2..5098e09d3c1 100644 --- a/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java +++ b/jdk/test/java/awt/TextArea/TextAreaScrolling/TextAreaScrolling.java @@ -24,7 +24,7 @@ /* @test @key headful - @bug 6180449 + @bug 6180449 8160764 @summary TextArea scrolls to its left when selecting the text from the end. @run main TextAreaScrolling */ @@ -42,6 +42,12 @@ public class TextAreaScrolling { Robot robot; TextAreaScrolling() { + try { + robot = new Robot(); + } catch (Exception ex) { + throw new RuntimeException("Robot Creation Failed"); + } + mainFrame = new Frame(); mainFrame.setSize(200, 200); mainFrame.setLocation(200, 200); @@ -49,19 +55,10 @@ public class TextAreaScrolling { textArea = new TextArea(); textArea.setText("1234 5678"); textArea.setSelectionStart(3); - textArea.setSelectionStart(4); + textArea.setSelectionEnd(4); mainFrame.add(textArea); mainFrame.setVisible(true); textArea.requestFocusInWindow(); - - try { - robot = new Robot(); - robot.setAutoWaitForIdle(true); - } catch (Exception ex) { - dispose(); - System.exit(0); - throw new RuntimeException("Robot Creation Failed"); - } } public void dispose() { @@ -71,6 +68,8 @@ public class TextAreaScrolling { } public void performTest() { + robot.waitForIdle(); + robot.delay(200); Point loc = textArea.getLocationOnScreen(); Rectangle textAreaBounds = new Rectangle(); textArea.getBounds(textAreaBounds); @@ -80,7 +79,7 @@ public class TextAreaScrolling { // Perform selection by scrolling to left from end of char sequence. robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseMove(textAreaBounds.x - 5, loc.y + 5); + robot.mouseMove(loc.x - 5, loc.y + 5); robot.mouseRelease(InputEvent.BUTTON1_MASK); // Perform double click on beginning word of TextArea @@ -91,11 +90,12 @@ public class TextAreaScrolling { robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.delay(100); + robot.waitForIdle(); if (textArea.getSelectedText().contentEquals("5678")) { dispose(); - throw new RuntimeException ("TextArea over scrolled towards left" - + "Expected selected text: '1234 ' and for mac '1234'" + throw new RuntimeException ("TextArea over scrolled towards left. " + + "Expected selected text: '1234 ' and for mac '1234' " + "Actual selected text: 5678"); } } From 0d7becfcb7568417afb9c19f2db24e7797afc1d6 Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Thu, 7 Jul 2016 16:47:37 +0530 Subject: [PATCH 08/80] 8156460: [macosx] Test case javax/swing/JPopupMenu/6827786/bug6827786.java fails 8160144: [macosx] The menuitem in the menu of the "Test Frame" can't work correctly 8160145: [macosx] Keep pressed the Alt, Shift & Ctrl Keys,and then Click 'ClickMe' button,the case failed automatically 8158621: The ALT key can not work with any key 8158485: The "File" menu's menuitems can not bring up information window or modal quit Dialog 8158501: [macosx] The checkbox can't be checked via an event generate on the menu 8158389: [macosx] Regression: javax/swing/JMenu/4213634/bug4213634.java 8158526: [macosx] java/awt/event/MouseEvent/MouseButtonsAndKeyMasksTest/MouseButtonsAndKeyMasksTest.java fails (invalid extended modifier info) 8158496: [macosx] Swing mnemonics broken on Mac 8158362: [macosx] Regression: at least java/awt/event/KeyEvent/AltCharAcceleratorTest/AltCharAcceleratorTest.java fails 8158512: [Regression] Test java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails 8158377: [macosx] Regression: java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeNextMnemonicKeyTypedTest Reviewed-by: alexsch, ssadetsky, aniyogi --- .../macosx/native/libawt_lwawt/awt/AWTEvent.m | 53 +++++++++++-------- .../macosx/native/libawt_lwawt/awt/CRobot.m | 25 ++------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index 69fe7a90406..cedb68c56ca 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -277,6 +277,16 @@ const nsKeyToJavaModifierTable[] = java_awt_event_InputEvent_CTRL_MASK, java_awt_event_KeyEvent_VK_CONTROL }, + { + NSCommandKeyMask, + //kCGSFlagsMaskAppleLeftCommandKey, + //kCGSFlagsMaskAppleRightCommandKey, + 55, + 54, + java_awt_event_InputEvent_META_DOWN_MASK, + java_awt_event_InputEvent_META_MASK, + java_awt_event_KeyEvent_VK_META + }, { NSAlternateKeyMask, //kCGSFlagsMaskAppleLeftAlternateKey, @@ -295,16 +305,6 @@ const nsKeyToJavaModifierTable[] = java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK, java_awt_event_KeyEvent_VK_ALT | java_awt_event_KeyEvent_VK_ALT_GRAPH }, - { - NSCommandKeyMask, - //kCGSFlagsMaskAppleLeftCommandKey, - //kCGSFlagsMaskAppleRightCommandKey, - 55, - 54, - java_awt_event_InputEvent_META_DOWN_MASK, - java_awt_event_InputEvent_META_MASK, - java_awt_event_KeyEvent_VK_META - }, // NSNumericPadKeyMask { NSHelpKeyMask, @@ -319,6 +319,7 @@ const nsKeyToJavaModifierTable[] = }; static BOOL leftAltKeyPressed; +static BOOL altGRPressed = NO; /* * Almost all unicode characters just go from NS to Java with no translation. @@ -559,20 +560,28 @@ NsKeyModifiersToJavaKeyInfo(NSUInteger nsFlags, unsigned short eventKeyCode, */ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods) { - jint javaModifiers = 0; - const struct _nsKeyToJavaModifier* cur; + jint javaModifiers = 0; + const struct _nsKeyToJavaModifier* cur; - for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { - if ((cur->nsMask & nsFlags) != 0) { - javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask; - if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) { - continue; - } - break; - } - } + for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { + if ((cur->nsMask & nsFlags) != 0) { + + if (cur->nsMask == NSAlternateKeyMask) { + if (leftAltKeyPressed == YES) { + javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask; + if (altGRPressed == NO) + break; + } else { + leftAltKeyPressed = YES; + altGRPressed = YES; + continue; + } + } + javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask; + } + } - return javaModifiers; + return javaModifiers; } /* diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m index 0de49711215..d3ee81c2175 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m @@ -261,27 +261,10 @@ Java_sun_lwawt_macosx_CRobot_keyEvent { CGKeyCode keyCode = GetCGKeyCode(javaKeyCode); - if ((javaKeyCode >= java_awt_event_KeyEvent_VK_0) && - (javaKeyCode <= java_awt_event_KeyEvent_VK_9)) - { - AXUIElementRef elem = AXUIElementCreateSystemWide(); - AXUIElementPostKeyboardEvent(elem, (CGCharCode)0, keyCode, keyPressed); - CFRelease(elem); - } else { - /* - * JDK-8155740: AXUIElementPostKeyboardEvent posts correct key codes for - * number keys whereas CGEventPost posts Numpad keys for corresponding - * number key. Hence AXUIElementPostKeyboardEvent is used for posting - * numbers and CGEventCreateKeyboardEvent/CGEventPost is used for other - * keys. - * Key code for modifier key is required to distinguish between ALT and - * ALT-GR key for fixing issue 8155740. - */ - CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed); - if (event != NULL) { - CGEventPost(kCGSessionEventTap, event); - CFRelease(event); - } + CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed); + if (event != NULL) { + CGEventPost(kCGSessionEventTap, event); + CFRelease(event); } } From 16aa730d2573248dd0575def55030481f409c37a Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 7 Jul 2016 15:39:19 +0300 Subject: [PATCH 09/80] 8160879: [PIT] CloseOnMouseClickPropertyTest fails with AA hint:Nonantialiased rendering mode exception Reviewed-by: ssadetsky, azvegint --- .../java.desktop/share/classes/sun/swing/SwingUtilities2.java | 2 +- .../swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index 13524ee051a..6f4c5f7045b 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -1093,7 +1093,7 @@ public class SwingUtilities2 { FontRenderContext frc = cache.get(key); if (frc == null) { - aaHint = (aaHint == null) ? VALUE_ANTIALIAS_OFF : aaHint; + aaHint = (aaHint == null) ? VALUE_TEXT_ANTIALIAS_OFF : aaHint; frc = new FontRenderContext(tx, aaHint, VALUE_FRACTIONALMETRICS_DEFAULT); cache.put(key, frc); diff --git a/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java b/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java index 29949095df5..e9bf230f45e 100644 --- a/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java +++ b/jdk/test/javax/swing/JMenuItem/8158566/CloseOnMouseClickPropertyTest.java @@ -37,7 +37,7 @@ import javax.swing.UIManager; /* * @test - * @bug 8158566 + * @bug 8158566 8160879 * @summary Provide a Swing property which modifies MenuItemUI behaviour */ public class CloseOnMouseClickPropertyTest { From 2e768f848bb50647064ff86c0d167b6bafd81755 Mon Sep 17 00:00:00 2001 From: Ajit Ghaisas Date: Fri, 8 Jul 2016 11:15:46 +0530 Subject: [PATCH 10/80] 8160421: Regression: JDK-8139192 causes NPE in java.awt.Toolkit.createCustomCursor() Reviewed-by: flar, prr --- .../sun/awt/image/OffScreenImageSource.java | 22 +++--- .../ImageConsumerUnregisterTest.java | 67 +++++++++++++++++++ 2 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 jdk/test/sun/awt/image/OffScreenImageSource/ImageConsumerUnregisterTest.java diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java b/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java index 12fe4f61394..acdb2afaf6e 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/OffScreenImageSource.java @@ -187,17 +187,19 @@ public class OffScreenImageSource implements ImageProducer { sendPixels(); theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); - try { - theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE); - } catch (RuntimeException e) { - // We did not previously call this method here and - // some image consumer filters were not prepared for it to be - // called at this time. We allow them to have runtime issues - // for this one call only without triggering the IMAGEERROR - // condition below. - e.printStackTrace(); + // If 'theconsumer' has not unregistered itself after previous call + if (theConsumer != null) { + try { + theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE); + } catch (RuntimeException e) { + // We did not previously call this method here and + // some image consumer filters were not prepared for it to be + // called at this time. We allow them to have runtime issues + // for this one call only without triggering the IMAGEERROR + // condition below. + e.printStackTrace(); + } } - } catch (NullPointerException e) { e.printStackTrace(); diff --git a/jdk/test/sun/awt/image/OffScreenImageSource/ImageConsumerUnregisterTest.java b/jdk/test/sun/awt/image/OffScreenImageSource/ImageConsumerUnregisterTest.java new file mode 100644 index 00000000000..888f1384d90 --- /dev/null +++ b/jdk/test/sun/awt/image/OffScreenImageSource/ImageConsumerUnregisterTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016, 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. + */ + +/* @test + * @bug 8160421 + * @summary Test to check OffScreenImageSource handles case where + * imageComplete(ImageConsumer.SINGLEFRAMEDONE) unregisters. + * @run main/othervm ImageConsumerUnregisterTest + */ + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public class ImageConsumerUnregisterTest extends javax.swing.JFrame { + + public static void main(String[] args) throws Exception { + + final java.awt.Component component = new TestBug8160421(); + + // Redirect the System.err stream and verify there is no + // stacktrace printed + ByteArrayOutputStream rs = new ByteArrayOutputStream(); + PrintStream obj = System.err; + System.setErr(new PrintStream(rs)); + + String str = ""; + + try { + // Test call + component.getToolkit().createCustomCursor( + component.getGraphicsConfiguration().createCompatibleImage( + 16, 16, java.awt.Transparency.BITMASK), + new java.awt.Point(0, 0), "Hidden"); + + // Convert the redirected System.err contents to a string + str = rs.toString(); + } finally { + // Reset System.err + System.setErr(obj); + + if (!str.isEmpty()) { + throw new RuntimeException("Invalid imageComplete(STATICIMAGEDONE) call"); + } + } + } +} + From 537455b8a3c6c4c7b2afa04500a22acb595f8ef0 Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Fri, 8 Jul 2016 19:32:52 +0530 Subject: [PATCH 11/80] 8158205: HiDPI hand cursor broken on Windows Reviewed-by: alexsch, ssadetsky --- .../native/libawt/windows/awt_Cursor.cpp | 10 +- .../Mouse/8158205/MouseHandCursorTest.java | 130 ++++++++++++++++++ 2 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/awt/Mouse/8158205/MouseHandCursorTest.java diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp index 3d116ecad08..36ceb1a4956 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp @@ -473,8 +473,14 @@ Java_sun_awt_windows_WGlobalCursorManager_getCursorPos(JNIEnv *env, POINT p; ::GetCursorPos(&p); - env->SetIntField(point, AwtCursor::pointXID, (jint)p.x); - env->SetIntField(point, AwtCursor::pointYID, (jint)p.y); + HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY); + int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor); + Devices::InstanceAccess devices; + AwtWin32GraphicsDevice *device = devices->GetDevice(screen); + int x = (device == NULL) ? p.x : device->ScaleDownX(p.x); + int y = (device == NULL) ? p.y : device->ScaleDownY(p.y); + env->SetIntField(point, AwtCursor::pointXID, x); + env->SetIntField(point, AwtCursor::pointYID, y); CATCH_BAD_ALLOC; } diff --git a/jdk/test/java/awt/Mouse/8158205/MouseHandCursorTest.java b/jdk/test/java/awt/Mouse/8158205/MouseHandCursorTest.java new file mode 100644 index 00000000000..f0aac10eb31 --- /dev/null +++ b/jdk/test/java/awt/Mouse/8158205/MouseHandCursorTest.java @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2016, 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. + */ + +/** + * @test + * @bug 8158205 + * @summary HiDPI hand cursor broken on Windows + * @run main/manual/othervm -Dsun.java2d.uiScale=2 MouseHandCursorTest + */ +import java.awt.Cursor; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.CountDownLatch; +import javax.swing.JFrame; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class MouseHandCursorTest { + + private static GridBagLayout layout; + private static JPanel mainControlPanel; + private static JPanel resultButtonPanel; + private static JLabel instructionText; + private static JButton passButton; + private static JButton failButton; + private static JFrame mainFrame; + private static CountDownLatch latch; + + public static void main(String[] args) throws Exception { + latch = new CountDownLatch(1); + createUI(); + latch.await(); + } + + public static void createUI() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + mainFrame = new JFrame("Hand Cursor Test"); + layout = new GridBagLayout(); + mainControlPanel = new JPanel(layout); + resultButtonPanel = new JPanel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + String instructions + = "
INSTRUCTIONS:

" + + "Check the mouse cursor type on frame.
" + + "If mouse cursor is hand cursor test passed else failed" + + "

"; + + instructionText = new JLabel(); + instructionText.setText(instructions); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionText, gbc); + + passButton = new JButton("Pass"); + passButton.setActionCommand("Pass"); + passButton.addActionListener((ActionEvent e) -> { + latch.countDown(); + mainFrame.dispose(); + }); + + failButton = new JButton("Fail"); + failButton.setActionCommand("Fail"); + failButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + latch.countDown(); + mainFrame.dispose(); + throw new RuntimeException("Test Failed"); + } + }); + gbc.gridx = 2; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 3; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + + gbc.gridx = 0; + gbc.gridy = 2; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.setSize(400, 200); + mainFrame.setLocationRelativeTo(null); + mainFrame.setVisible(true); + + mainFrame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + latch.countDown(); + mainFrame.dispose(); + } + }); + mainFrame.getContentPane().setCursor(Cursor. + getPredefinedCursor(Cursor.HAND_CURSOR)); + } + }); + } +} From 190b31b1336c0a16a85376f42379a697fc92c28c Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Fri, 8 Jul 2016 18:43:12 +0300 Subject: [PATCH 12/80] 8149115: [hidpi] Linux: display-wise scaling factor should probably be taken into account Reviewed-by: alexsch, azvegint --- jdk/make/lib/Awt2dLibraries.gmk | 2 +- .../classes/sun/awt/X11GraphicsDevice.java | 12 +- .../common/awt/systemscale/systemScale.c | 187 +++++++++++++++++- .../common/awt/systemscale/systemScale.h | 3 +- .../native/libawt_xawt/awt/awt_GraphicsEnv.c | 43 +++- 5 files changed, 228 insertions(+), 19 deletions(-) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 25778fa52ac..c9f267e368e 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -931,7 +931,7 @@ ifndef BUILD_HEADLESS_ONLY LIBSPLASHSCREEN_LDFLAGS := -delayload:user32.dll LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib else - LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread + LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl endif $(eval $(call SetupNativeCompilation,BUILD_LIBSPLASHSCREEN, \ diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index 14ff9a5d45b..0f81f4e911f 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -281,7 +281,7 @@ public final class X11GraphicsDevice extends GraphicsDevice int width, int height, int displayMode); private static native void resetNativeData(int screen); - private static native int getNativeScaleFactor(int screen); + private static native double getNativeScaleFactor(int screen); /** * Returns true only if: @@ -516,6 +516,11 @@ public final class X11GraphicsDevice extends GraphicsDevice return scale; } + public int getNativeScale() { + isXrandrExtensionSupported(); + return (int)Math.round(getNativeScaleFactor(screen)); + } + private int initScaleFactor() { if (SunGraphicsEnvironment.isUIScaleEnabled()) { @@ -525,8 +530,7 @@ public final class X11GraphicsDevice extends GraphicsDevice if (debugScale >= 1) { return (int) debugScale; } - - int nativeScale = getNativeScaleFactor(screen); + int nativeScale = getNativeScale(); return nativeScale >= 1 ? nativeScale : 1; } diff --git a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c index fd574a89621..c8a5810370f 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.c @@ -22,23 +22,171 @@ */ #include "systemScale.h" +#include "jni.h" +#include "jni_util.h" +#include "jvm_md.h" +#include +#include #include +#include -int getNativeScaleFactor() { +typedef void* g_settings_schema_source_get_default(); +typedef void* g_settings_schema_source_ref(void *); +typedef void g_settings_schema_source_unref(void *); +typedef void* g_settings_schema_source_lookup(void *, char *, int); +typedef int g_settings_schema_has_key(void *, char *); +typedef void* g_settings_new_full(void *, void *, char *); +typedef void* g_settings_get_value(void *, char *); +typedef int g_variant_is_of_type(void *, char *); +typedef unsigned long g_variant_n_children(void *); +typedef void* g_variant_get_child_value(void *, unsigned long); +typedef void g_variant_unref(void *); +typedef char* g_variant_get_string(void *, unsigned long *); +typedef int g_variant_get_int32(void *); +typedef double g_variant_get_double(void *); - static int scale = -2.0; +static g_settings_schema_has_key* fp_g_settings_schema_has_key; +static g_settings_new_full* fp_g_settings_new_full; +static g_settings_get_value* fp_g_settings_get_value; +static g_variant_is_of_type* fp_g_variant_is_of_type; +static g_variant_n_children* fp_g_variant_n_children; +static g_variant_get_child_value* fp_g_variant_get_child_value; +static g_variant_get_string* fp_g_variant_get_string; +static g_variant_get_int32* fp_g_variant_get_int32; +static g_variant_get_double* fp_g_variant_get_double; +static g_variant_unref* fp_g_variant_unref; - if (scale == -2) { - scale = getScale("J2D_UISCALE"); +static void* get_schema_value(char *name, char *key) { + static void *lib_handle; + static int initialized = 0; + static void * default_schema; + static g_settings_schema_source_lookup* schema_lookup; + void *schema = NULL, *fp = NULL; + if (!initialized) { + initialized = 1; + lib_handle = dlopen(JNI_LIB_NAME("gio-2.0"), RTLD_GLOBAL | RTLD_LAZY); + if (!lib_handle) { + CHECK_NULL_RETURN(lib_handle = + dlopen(VERSIONED_JNI_LIB_NAME("gio-2.0", "0"), + RTLD_GLOBAL | RTLD_LAZY), NULL); + } + CHECK_NULL_RETURN(fp_g_settings_schema_has_key = + (g_settings_schema_has_key*) + dlsym(lib_handle, "g_settings_schema_has_key"), NULL); + CHECK_NULL_RETURN(fp_g_settings_new_full = + (g_settings_new_full*) + dlsym(lib_handle, "g_settings_new_full"), NULL); + CHECK_NULL_RETURN(fp_g_settings_get_value = + (g_settings_get_value*) + dlsym(lib_handle, "g_settings_get_value"), NULL); + CHECK_NULL_RETURN(fp_g_variant_is_of_type = + (g_variant_is_of_type*) + dlsym(lib_handle, "g_variant_is_of_type"), NULL); + CHECK_NULL_RETURN(fp_g_variant_n_children = + (g_variant_n_children*) + dlsym(lib_handle, "g_variant_n_children"), NULL); + CHECK_NULL_RETURN(fp_g_variant_get_child_value = + (g_variant_get_child_value*) + dlsym(lib_handle, "g_variant_get_child_value"), NULL); + CHECK_NULL_RETURN(fp_g_variant_get_string = + (g_variant_get_string*) + dlsym(lib_handle, "g_variant_get_string"), NULL); + CHECK_NULL_RETURN(fp_g_variant_get_int32 = + (g_variant_get_int32*) + dlsym(lib_handle, "g_variant_get_int32"), NULL); + CHECK_NULL_RETURN(fp_g_variant_get_double = + (g_variant_get_double*) + dlsym(lib_handle, "g_variant_get_double"), NULL); + CHECK_NULL_RETURN(fp_g_variant_unref = + (g_variant_unref*) + dlsym(lib_handle, "g_variant_unref"), NULL); + + fp = dlsym(lib_handle, "g_settings_schema_source_get_default"); + if (fp) { + default_schema = ((g_settings_schema_source_get_default*)fp)(); + } + if (default_schema) { + fp = dlsym(lib_handle, "g_settings_schema_source_ref"); + if (fp) { + ((g_settings_schema_source_ref*)fp)(default_schema); + } + } + schema_lookup = (g_settings_schema_source_lookup*) + dlsym(lib_handle, "g_settings_schema_source_lookup"); } - if (scale >= 1) { - return (int) scale; + if (!default_schema || !schema_lookup) { + return NULL; } - return getScale("GDK_SCALE"); + + schema = schema_lookup(default_schema, name, 1); + if (schema) { + if (fp_g_settings_schema_has_key(schema, key)) { + void *settings = fp_g_settings_new_full(schema, NULL, NULL); + if (settings) { + return fp_g_settings_get_value(settings, key); + } + } + } + return NULL; } -int getScale(const char *name) { + +static double getDesktopScale(char *output_name) { + double result = -1; + if(output_name) { + void *value = get_schema_value("com.ubuntu.user-interface", + "scale-factor"); + if (value) { + if(fp_g_variant_is_of_type(value, "a{si}")) { + int num = fp_g_variant_n_children(value); + int i = 0; + while (i < num) { + void *entry = fp_g_variant_get_child_value(value, i++); + if (entry) { + void *screen = fp_g_variant_get_child_value(entry, 0); + void *scale = fp_g_variant_get_child_value(entry, 1); + if (screen && scale) { + char *name = fp_g_variant_get_string(screen, NULL); + if (name && strcmp(name, output_name)) { + result = fp_g_variant_get_int32(scale) / 8.; + } + fp_g_variant_unref(screen); + fp_g_variant_unref(scale); + } + fp_g_variant_unref(entry); + } + if (result > 0) { + break; + } + } + } + fp_g_variant_unref(value); + } + if (result > 0) { + value = get_schema_value("com.canonical.Unity.Interface", + "text-scale-factor"); + if (value && fp_g_variant_is_of_type(value, "d")) { + result *= fp_g_variant_get_double(value); + fp_g_variant_unref(value); + } + } + } + + if (result <= 0) { + void *value = get_schema_value("org.gnome.desktop.interface", + "text-scaling-factor"); + if (value && fp_g_variant_is_of_type(value, "d")) { + result = fp_g_variant_get_double(value); + fp_g_variant_unref(value); + } + } + + return result; + +} + +static int getScale(const char *name) { char *uiScale = getenv(name); if (uiScale != NULL) { double scale = strtod(uiScale, NULL); @@ -50,3 +198,26 @@ int getScale(const char *name) { return -1; } +double getNativeScaleFactor(char *output_name) { + static int scale = -2.0; + double native_scale = 0; + int gdk_scale = 0; + + if (scale == -2) { + scale = getScale("J2D_UISCALE"); + } + + if (scale > 0) { + return scale; + } + + native_scale = getDesktopScale(output_name); + + if (native_scale <= 0) { + native_scale = 1; + } + + gdk_scale = getScale("GDK_SCALE"); + + return gdk_scale > 0 ? native_scale * gdk_scale : native_scale; +} diff --git a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h index a45d18ccdab..697a8bd33d3 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h +++ b/jdk/src/java.desktop/unix/native/common/awt/systemscale/systemScale.h @@ -26,8 +26,7 @@ #include #include -int getNativeScaleFactor(); -int getScale(const char *uiScale); +double getNativeScaleFactor(); #endif diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 40aa4463085..8339a195828 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -2141,15 +2141,50 @@ Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive * End DisplayMode/FullScreen support */ +static char *get_output_screen_name(JNIEnv *env, int screen) { + if (!awt_XRRGetScreenResources || !awt_XRRGetOutputInfo) { + return NULL; + } + char *name = NULL; + AWT_LOCK(); + int scr = 0, out = 0; + if (usingXinerama && XScreenCount(awt_display) > 0) { + out = screen; + } else { + scr = screen; + } + + XRRScreenResources *res = awt_XRRGetScreenResources(awt_display, + RootWindow(awt_display, scr)); + if (res) { + if (res->noutput > out) { + XRROutputInfo *output_info = awt_XRRGetOutputInfo(awt_display, + res, res->outputs[out]); + if (output_info) { + if (output_info->name) { + name = strdup(output_info->name); + } + awt_XRRFreeOutputInfo(output_info); + } + } + awt_XRRFreeScreenResources(res); + } + AWT_UNLOCK(); + return name; +} /* * Class: sun_awt_X11GraphicsDevice * Method: getNativeScaleFactor - * Signature: (I)I + * Signature: (I)D */ -JNIEXPORT jint JNICALL +JNIEXPORT jdouble JNICALL Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor (JNIEnv *env, jobject this, jint screen) { - - return getNativeScaleFactor(); + char *name = get_output_screen_name(env, screen); + double scale = getNativeScaleFactor(name); + if (name) { + free(name); + } + return scale; } From 876a0a5b940fe924cb79711aa1ba3ea87990e1ff Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Fri, 8 Jul 2016 20:28:28 +0300 Subject: [PATCH 13/80] 8152968: JTree Collapse Buttons Clipped Off Under GTK Reviewed-by: alexsch --- .../classes/com/sun/java/swing/plaf/gtk/GTKPainter.java | 4 ++-- .../classes/com/sun/java/swing/plaf/gtk/GTKStyle.java | 7 ++++++- .../unix/native/libawt_xawt/awt/gtk3_interface.c | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java index a607d4c41d4..56ec905ba33 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java @@ -1339,14 +1339,14 @@ class GTKPainter extends SynthPainter { Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), - ExpanderStyle.EXPANDED, "treeview", x, y, w, h); + ExpanderStyle.EXPANDED, "expander", x, y, w, h); } public void paintTreeCollapsedIcon(SynthContext context, Graphics g, int state, int x, int y, int w, int h) { ENGINE.paintExpander(g, context, Region.TREE, GTKLookAndFeel.synthStateToGTKState(context.getRegion(), state), - ExpanderStyle.COLLAPSED, "treeview", x, y, w, h); + ExpanderStyle.COLLAPSED, "expander", x, y, w, h); } public void paintCheckBoxIcon(SynthContext context, diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index 2c60551dd04..b3d32695d38 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -854,6 +854,12 @@ class GTKStyle extends SynthStyle implements GTKConstants { return indicatorSpacing + focusSize + focusPad; } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) { return true; + } else if ("Tree.expanderSize".equals(key)) { + Object value = getClassSpecificValue("expander-size"); + if (value instanceof Integer) { + return (Integer)value + 4; + } + return null; } // Is it a stock icon ? @@ -1136,7 +1142,6 @@ class GTKStyle extends SynthStyle implements GTKConstants { CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length"); CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border"); CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size"); - CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size"); CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width"); CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width"); CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color"); diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c index fcb4bb221fb..df501fb338b 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c @@ -1586,13 +1586,17 @@ static void gtk3_paint_expander(WidgetType widget_type, GtkStateType state_type, fp_gtk_style_context_save (context); GtkStateFlags flags = get_gtk_flags(state_type); + if (expander_style == GTK_EXPANDER_EXPANDED) { + flags |= GTK_STATE_FLAG_ACTIVE; + } + fp_gtk_style_context_set_state(context, flags); if (detail != 0) { transform_detail_string(detail, context); } - fp_gtk_render_expander (context, cr, x, y, width, height); + fp_gtk_render_expander (context, cr, x + 2, y + 2, width - 4, height - 4); fp_gtk_style_context_restore (context); } From c41a009a6236f86606c7f368a38604b54697786a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Mon, 11 Jul 2016 10:45:54 +0530 Subject: [PATCH 14/80] 5049012: PrintToFile option is not disabled for flavors that do not support destination Reviewed-by: prr, jdv --- .../classes/sun/print/ServiceDialog.java | 16 +- .../attribute/ServiceDialogValidateTest.java | 154 ++++++++++++++++++ 2 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 jdk/test/javax/print/attribute/ServiceDialogValidateTest.java diff --git a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java index 0f7578f7451..6d2bb99bfbf 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -74,7 +74,7 @@ import sun.print.SunPageSelection; import java.awt.event.KeyEvent; import java.net.URISyntaxException; import java.lang.reflect.Field; - +import java.net.MalformedURLException; /** * A class which implements a cross-platform print dialog. @@ -932,12 +932,18 @@ public class ServiceDialog extends JDialog implements ActionListener { allowedToPrintToFile() : false; // setup Destination (print-to-file) widgets - if (psCurrent.isAttributeCategorySupported(dstCategory)) { - dstSupported = true; - } Destination dst = (Destination)asCurrent.get(dstCategory); if (dst != null) { - dstSelected = true; + try { + dst.getURI().toURL(); + if (psCurrent.isAttributeValueSupported(dst, docFlavor, + asCurrent)) { + dstSupported = true; + dstSelected = true; + } + } catch (MalformedURLException ex) { + dstSupported = true; + } } cbPrintToFile.setEnabled(dstSupported && dstAllowed); cbPrintToFile.setSelected(dstSelected && dstAllowed diff --git a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java new file mode 100644 index 00000000000..4216da6f015 --- /dev/null +++ b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2016, 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. + */ +/* + * @test + * @bug 5049012 + * @summary Verify if PrintToFile option is disabled for flavors that do not + * support Destination + * @requires (os.family == "linux") + * @run main/manual ServiceDialogValidateTest + */ +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.io.File; +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.standard.Destination; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class ServiceDialogValidateTest { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + + private static void printTest() { + PrintService defService = null, service[] = null; + HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet(); + DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG; + + service = PrintServiceLookup.lookupPrintServices(flavor, null); + defService = PrintServiceLookup.lookupDefaultPrintService(); + + if ((service == null) || (service.length == 0)) { + throw new RuntimeException("No Printer services found"); + } + File f = new File("output.ps"); + Destination d = new Destination(f.toURI()); + prSet.add(d); + if (defService != null) { + System.out.println("isAttrCategory Supported? " + + defService.isAttributeCategorySupported(Destination.class)); + System.out.println("isAttrValue Supported? " + + defService.isAttributeValueSupported(d, flavor, null)); + } + + defService = ServiceUI.printDialog(null, 100, 100, service, defService, + flavor, prSet); + + } + + /** + * Starts the application. + */ + public static void main(java.lang.String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(ServiceDialogValidateTest::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("PrintToFile option is not disabled " + + "for flavors that do not support destination"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Visual inspection of print dialog is required.\n" + + " A print dialog will be shown.\n " + + " Please verify Print-To-File option is disabled.\n" + + " Press Cancel to close the print dialog.\n" + + " If Print-To-File option is disabled, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + } +} + + From b2c4d31401e801696dd4ef8528b3138ca39d2987 Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Mon, 11 Jul 2016 14:56:17 +0530 Subject: [PATCH 15/80] 8159168: [hidpi] Window.setShape() works incorrectly on HiDPI Reviewed-by: alexsch, ssadetsky --- .../sun/awt/windows/WComponentPeer.java | 7 ++ .../java/awt/Window/8159168/SetShapeTest.java | 92 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 jdk/test/java/awt/Window/8159168/SetShapeTest.java diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java index f07857b80b4..5b201f5a02e 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java @@ -55,6 +55,7 @@ import sun.awt.event.IgnorePaintEvent; import java.awt.dnd.DropTarget; import java.awt.dnd.peer.DropTargetPeer; +import java.awt.geom.AffineTransform; import sun.awt.AWTAccessor; import sun.util.logging.PlatformLogger; @@ -1128,6 +1129,12 @@ public abstract class WComponentPeer extends WObjectPeer } if (shape != null) { + AffineTransform tx = winGraphicsConfig.getDefaultTransform(); + double scaleX = tx.getScaleX(); + double scaleY = tx.getScaleY(); + if (scaleX != 1 || scaleY != 1) { + shape = shape.getScaledRegion(scaleX, scaleY); + } setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(), (shape.isRectangular() ? null : shape)); } else { diff --git a/jdk/test/java/awt/Window/8159168/SetShapeTest.java b/jdk/test/java/awt/Window/8159168/SetShapeTest.java new file mode 100644 index 00000000000..19670a5f46e --- /dev/null +++ b/jdk/test/java/awt/Window/8159168/SetShapeTest.java @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2016, 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. + */ + +/** + * @test + * @bug 8159168 + * @summary [hidpi] Window.setShape() works incorrectly on HiDPI + * @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest + */ +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.Window; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; +import java.awt.Robot; +import javax.swing.SwingUtilities; + +public class SetShapeTest { + + private static Window window; + private static Frame background; + + public static void main(String[] args) throws Exception { + createUI(); + Robot robot = new Robot(); + robot.waitForIdle(); + Rectangle rect = window.getBounds(); + rect.x += rect.width - 10; + rect.y += rect.height - 10; + Color c = robot.getPixelColor(rect.x, rect.y); + try { + if (!c.equals(Color.RED)) { + throw new RuntimeException("Test Failed"); + } + } finally { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + background.dispose(); + window.dispose(); + } + }); + } + } + + private static void createUI() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + background = new Frame(); + background.setUndecorated(true); + background.setBackground(Color.blue); + background.setSize(300, 300); + background.setLocation(100, 100); + background.setVisible(true); + window = new Window(background); + window.setBackground(Color.red); + window.add(new Panel(), BorderLayout.CENTER); + window.setLocation(200, 200); + window.setSize(100, 100); + Area a = new Area(); + a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100))); + window.setShape(a); + window.setVisible(true); + window.toFront(); + } + }); + } +} From 11c3f1fedb96d0a3cd34a6f1143253979afd807c Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Mon, 11 Jul 2016 16:39:11 +0530 Subject: [PATCH 16/80] 8160882: [PIT][TEST_BUG] a trap of java/awt/print/PrinterJob/PrintTestLexmarkIQ.java Reviewed-by: yan --- .../awt/print/PrinterJob/PrintTestLexmarkIQ.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java b/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java index 3cc424f5037..cb82100efb0 100644 --- a/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java +++ b/jdk/test/java/awt/print/PrinterJob/PrintTestLexmarkIQ.java @@ -20,9 +20,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* + /* * @test - * @bug 6966350 + * @bug 6966350 8160882 * @summary Verifies if Empty pages are printed on Lexmark E352dn PS3 * with "1200 IQ" setting * @run main/manual PrintTestLexmarkIQ @@ -33,6 +33,8 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -145,6 +147,13 @@ public class PrintTestLexmarkIQ implements Printable { dialog.add(mainPanel); dialog.pack(); dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); } public int print(Graphics g, PageFormat pf, int pi) From a4af4c68ab7c394810a011dd124dc2e30a99647d Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Mon, 11 Jul 2016 19:54:24 +0300 Subject: [PATCH 17/80] 8158993: Service Menu services Reviewed-by: prr, mschoene --- .../sun/awt/windows/WMenuItemPeer.java | 3 +- .../classes/sun/awt/windows/WMenuPeer.java | 4 +- .../classes/sun/awt/windows/WObjectPeer.java | 39 ++++++++++++++++++- .../sun/awt/windows/WPopupMenuPeer.java | 3 +- .../native/libawt/windows/awt_Frame.cpp | 10 ++++- .../native/libawt/windows/awt_MenuBar.cpp | 5 ++- .../native/libawt/windows/awt_MenuBar.h | 5 ++- 7 files changed, 62 insertions(+), 7 deletions(-) diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java index 9f681e76fbd..5a581193b8d 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -107,6 +107,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { this.target = target; this.parent = (WMenuPeer) WToolkit.targetToPeer(target.getParent()); this.isCheckbox = isCheckbox; + parent.addChildPeer(this); create(parent); // fix for 5088782: check if menu object is created successfully checkMenuCreation(); diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java index 567af925d38..9272a48bac5 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -51,10 +51,12 @@ class WMenuPeer extends WMenuItemPeer implements MenuPeer { if (parent instanceof MenuBar) { WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(parent); this.parent = mbPeer; + mbPeer.addChildPeer(this); createMenu(mbPeer); } else if (parent instanceof Menu) { this.parent = (WMenuPeer) WToolkit.targetToPeer(parent); + this.parent.addChildPeer(this); createSubMenu(this.parent); } else { diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java index c456df27dd9..b5324076486 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -24,6 +24,9 @@ */ package sun.awt.windows; +import java.util.Map; +import java.util.WeakHashMap; + abstract class WObjectPeer { static { @@ -45,6 +48,8 @@ abstract class WObjectPeer { // used to synchronize the state of this peer private final Object stateLock = new Object(); + private volatile Map childPeers; + public static WObjectPeer getPeerForTarget(Object t) { WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t); return peer; @@ -77,6 +82,9 @@ abstract class WObjectPeer { } if (call_disposeImpl) { + if (childPeers != null) { + disposeChildPeers(); + } disposeImpl(); } } @@ -88,4 +96,33 @@ abstract class WObjectPeer { * Initialize JNI field and method IDs */ private static native void initIDs(); + + // if a child peer existence depends on this peer, add it to this collection + final void addChildPeer(WObjectPeer child) { + synchronized (getStateLock()) { + if (childPeers == null) { + childPeers = new WeakHashMap<>(); + } + if (isDisposed()) { + throw new IllegalStateException("Parent peer is disposed"); + } + childPeers.put(child, this); + } + } + + // called to dispose dependent child peers + private void disposeChildPeers() { + synchronized (getStateLock()) { + for (WObjectPeer child : childPeers.keySet()) { + if (child != null) { + try { + child.dispose(); + } + catch (Exception e) { + // ignored + } + } + } + } + } } diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java index 6818be35dba..d37858dff6b 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -58,6 +58,7 @@ final class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { parent = WToolkit.getNativeContainer((Component)parent); parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent); } + parentPeer.addChildPeer(this); createMenu(parentPeer); // fix for 5088782: check if menu object is created successfully checkMenuCreation(); diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp index ed8311ff3b3..83f48f1900b 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -1113,11 +1113,19 @@ AwtMenuBar* AwtFrame::GetMenuBar() void AwtFrame::SetMenuBar(AwtMenuBar* mb) { + if (menuBar) { + menuBar->SetFrame(NULL); + } menuBar = mb; if (mb == NULL) { // Remove existing menu bar, if any. ::SetMenu(GetHWnd(), NULL); } else { + AwtFrame* oldFrame = menuBar->GetFrame(); + if (oldFrame && oldFrame != this) { + oldFrame->SetMenuBar(NULL); + } + menuBar->SetFrame(this); if (menuBar->GetHMenu() != NULL) { ::SetMenu(GetHWnd(), menuBar->GetHMenu()); } diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp index d15e2809a73..b62775f8b1b 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -58,6 +58,9 @@ AwtMenuBar::~AwtMenuBar() void AwtMenuBar::Dispose() { + if (m_frame != NULL && m_frame->GetMenuBar() == this) { + m_frame->SetMenuBar(NULL); + } m_frame = NULL; AwtMenu::Dispose(); diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h index b4291f17a60..797cf0a58bd 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, 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 @@ -63,6 +63,9 @@ public: virtual AwtMenuBar* GetMenuBar() { return this; } INLINE AwtFrame* GetFrame() { return m_frame; } + INLINE void SetFrame(AwtFrame* frame) { + m_frame = frame; + } virtual HWND GetOwnerHWnd(); virtual void RedrawMenuBar(); From 653531139e45258fb91587df433e0d31e7976da0 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Mon, 11 Jul 2016 20:36:13 +0300 Subject: [PATCH 18/80] 8161148: Rollback JDK-8158993 from client repo Reviewed-by: prr, mschoene --- .../sun/awt/windows/WMenuItemPeer.java | 3 +- .../classes/sun/awt/windows/WMenuPeer.java | 4 +- .../classes/sun/awt/windows/WObjectPeer.java | 39 +------------------ .../sun/awt/windows/WPopupMenuPeer.java | 3 +- .../native/libawt/windows/awt_Frame.cpp | 10 +---- .../native/libawt/windows/awt_MenuBar.cpp | 5 +-- .../native/libawt/windows/awt_MenuBar.h | 5 +-- 7 files changed, 7 insertions(+), 62 deletions(-) diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java index 5a581193b8d..9f681e76fbd 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -107,7 +107,6 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { this.target = target; this.parent = (WMenuPeer) WToolkit.targetToPeer(target.getParent()); this.isCheckbox = isCheckbox; - parent.addChildPeer(this); create(parent); // fix for 5088782: check if menu object is created successfully checkMenuCreation(); diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java index 9272a48bac5..567af925d38 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, 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 @@ -51,12 +51,10 @@ class WMenuPeer extends WMenuItemPeer implements MenuPeer { if (parent instanceof MenuBar) { WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(parent); this.parent = mbPeer; - mbPeer.addChildPeer(this); createMenu(mbPeer); } else if (parent instanceof Menu) { this.parent = (WMenuPeer) WToolkit.targetToPeer(parent); - this.parent.addChildPeer(this); createSubMenu(this.parent); } else { diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java index b5324076486..c456df27dd9 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WObjectPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2008, 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 @@ -24,9 +24,6 @@ */ package sun.awt.windows; -import java.util.Map; -import java.util.WeakHashMap; - abstract class WObjectPeer { static { @@ -48,8 +45,6 @@ abstract class WObjectPeer { // used to synchronize the state of this peer private final Object stateLock = new Object(); - private volatile Map childPeers; - public static WObjectPeer getPeerForTarget(Object t) { WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t); return peer; @@ -82,9 +77,6 @@ abstract class WObjectPeer { } if (call_disposeImpl) { - if (childPeers != null) { - disposeChildPeers(); - } disposeImpl(); } } @@ -96,33 +88,4 @@ abstract class WObjectPeer { * Initialize JNI field and method IDs */ private static native void initIDs(); - - // if a child peer existence depends on this peer, add it to this collection - final void addChildPeer(WObjectPeer child) { - synchronized (getStateLock()) { - if (childPeers == null) { - childPeers = new WeakHashMap<>(); - } - if (isDisposed()) { - throw new IllegalStateException("Parent peer is disposed"); - } - childPeers.put(child, this); - } - } - - // called to dispose dependent child peers - private void disposeChildPeers() { - synchronized (getStateLock()) { - for (WObjectPeer child : childPeers.keySet()) { - if (child != null) { - try { - child.dispose(); - } - catch (Exception e) { - // ignored - } - } - } - } - } } diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java index d37858dff6b..6818be35dba 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, 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 @@ -58,7 +58,6 @@ final class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { parent = WToolkit.getNativeContainer((Component)parent); parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent); } - parentPeer.addChildPeer(this); createMenu(parentPeer); // fix for 5088782: check if menu object is created successfully checkMenuCreation(); diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp index 83f48f1900b..ed8311ff3b3 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, 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 @@ -1113,19 +1113,11 @@ AwtMenuBar* AwtFrame::GetMenuBar() void AwtFrame::SetMenuBar(AwtMenuBar* mb) { - if (menuBar) { - menuBar->SetFrame(NULL); - } menuBar = mb; if (mb == NULL) { // Remove existing menu bar, if any. ::SetMenu(GetHWnd(), NULL); } else { - AwtFrame* oldFrame = menuBar->GetFrame(); - if (oldFrame && oldFrame != this) { - oldFrame->SetMenuBar(NULL); - } - menuBar->SetFrame(this); if (menuBar->GetHMenu() != NULL) { ::SetMenu(GetHWnd(), menuBar->GetHMenu()); } diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp index b62775f8b1b..d15e2809a73 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2014, 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 @@ -58,9 +58,6 @@ AwtMenuBar::~AwtMenuBar() void AwtMenuBar::Dispose() { - if (m_frame != NULL && m_frame->GetMenuBar() == this) { - m_frame->SetMenuBar(NULL); - } m_frame = NULL; AwtMenu::Dispose(); diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h index 797cf0a58bd..b4291f17a60 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuBar.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2011, 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 @@ -63,9 +63,6 @@ public: virtual AwtMenuBar* GetMenuBar() { return this; } INLINE AwtFrame* GetFrame() { return m_frame; } - INLINE void SetFrame(AwtFrame* frame) { - m_frame = frame; - } virtual HWND GetOwnerHWnd(); virtual void RedrawMenuBar(); From c584705096f8ccd38c0bbc72ce9e89afe2af3e5c Mon Sep 17 00:00:00 2001 From: Mario Torre Date: Mon, 11 Jul 2016 16:52:50 +0200 Subject: [PATCH 19/80] 8150954: Taking screenshots on x11 composite desktop produce wrong result The AWT Robot X11 code that takes screenshots uses the default root window, which may not contain the final composited desktop. Reviewed-by: alexsch, ssadetsky --- jdk/make/mapfiles/libawt_xawt/mapfile-vers | 1 + .../unix/classes/sun/awt/X11/XRobotPeer.java | 24 ++++-- .../unix/native/libawt_xawt/awt/awt_Robot.c | 84 ++++++++++++++++++- 3 files changed, 100 insertions(+), 9 deletions(-) diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index b56fad43b4f..461c1ba9f48 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -164,6 +164,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl; Java_sun_awt_X11_XRobotPeer_mouseWheelImpl; Java_sun_awt_X11_XRobotPeer_setup; + Java_sun_awt_X11_XRobotPeer_loadNativeLibraries; Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl; Java_java_awt_Component_initIDs; Java_java_awt_Container_initIDs; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java index 368d034687e..10b28cdfafb 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java @@ -35,8 +35,16 @@ import sun.awt.X11GraphicsEnvironment; class XRobotPeer implements RobotPeer { - private static volatile boolean isGtkSupported; + static final boolean tryGtk; + static { + loadNativeLibraries(); + tryGtk = Boolean.getBoolean("awt.robot.gtk"); + } + + private static boolean isGtkSupported = false; + private static volatile boolean useGtk; private X11GraphicsConfig xgc = null; + /* * native implementation uses some static shared data (pipes, processes) * so use a class lock to synchronize native method calls @@ -49,13 +57,14 @@ class XRobotPeer implements RobotPeer { setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks()); - Toolkit toolkit = Toolkit.getDefaultToolkit(); - if (!isGtkSupported) { - if (toolkit instanceof UNIXToolkit - && ((UNIXToolkit) toolkit).loadGTK()) { + boolean isGtkSupported = false; + if (tryGtk) { + if (tk instanceof UNIXToolkit && ((UNIXToolkit) tk).loadGTK()) { isGtkSupported = true; } } + + useGtk = (tryGtk && isGtkSupported); } @Override @@ -104,7 +113,7 @@ class XRobotPeer implements RobotPeer { public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; getRGBPixelsImpl(xgc, x, y, 1, 1, xgc.getScale(), pixelArray, - isGtkSupported); + useGtk); return pixelArray[0]; } @@ -112,11 +121,12 @@ class XRobotPeer implements RobotPeer { public int [] getRGBPixels(Rectangle bounds) { int pixelArray[] = new int[bounds.width*bounds.height]; getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, - xgc.getScale(), pixelArray, isGtkSupported); + xgc.getScale(), pixelArray, useGtk); return pixelArray; } private static synchronized native void setup(int numberOfButtons, int[] buttonDownMasks); + private static native void loadNativeLibraries(); private static synchronized native void mouseMoveImpl(X11GraphicsConfig xgc, int x, int y); private static synchronized native void mousePressImpl(int buttons); diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c index 0e06972207f..41bb1004a91 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c @@ -27,6 +27,9 @@ #error This file should not be included in headless library #endif +#include "jvm_md.h" +#include + #include "awt_p.h" #include "awt_GraphicsEnv.h" #define XK_MISCELLANY @@ -50,11 +53,46 @@ #include #endif +static Bool (*compositeQueryExtension) (Display*, int*, int*); +static Status (*compositeQueryVersion) (Display*, int*, int*); +static Window (*compositeGetOverlayWindow) (Display *, Window); + extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs; static jint * masks; static jint num_buttons; +static void *xCompositeHandle; + +static const char* XCOMPOSITE = JNI_LIB_NAME("Xcomposite"); +static const char* XCOMPOSITE_VERSIONED = VERSIONED_JNI_LIB_NAME("Xcomposite", "1"); + +static Bool checkXCompositeFunctions(void) { + return (compositeQueryExtension != NULL && + compositeQueryVersion != NULL && + compositeGetOverlayWindow != NULL); +} + +static void initXCompositeFunctions(void) { + + if (xCompositeHandle == NULL) { + xCompositeHandle = dlopen(XCOMPOSITE, RTLD_LAZY | RTLD_GLOBAL); + if (xCompositeHandle == NULL) { + xCompositeHandle = dlopen(XCOMPOSITE_VERSIONED, RTLD_LAZY | RTLD_GLOBAL); + } + } + //*(void **)(&asyncGetCallTraceFunction) + if (xCompositeHandle != NULL) { + *(void **)(&compositeQueryExtension) = dlsym(xCompositeHandle, "XCompositeQueryExtension"); + *(void **)(&compositeQueryVersion) = dlsym(xCompositeHandle, "XCompositeQueryVersion"); + *(void **)(&compositeGetOverlayWindow) = dlsym(xCompositeHandle, "XCompositeGetOverlayWindow"); + } + + if (xCompositeHandle && !checkXCompositeFunctions()) { + dlclose(xCompositeHandle); + } +} + static int32_t isXTestAvailable() { int32_t major_opcode, first_event, first_error; int32_t event_basep, error_basep, majorp, minorp; @@ -89,6 +127,35 @@ static int32_t isXTestAvailable() { return isXTestAvailable; } +static Bool hasXCompositeOverlayExtension(Display *display) { + + int xoverlay = False; + int eventBase, errorBase; + if (checkXCompositeFunctions() && + compositeQueryExtension(display, &eventBase, &errorBase)) + { + int major = 0; + int minor = 0; + + compositeQueryVersion(display, &major, &minor); + if (major > 0 || minor >= 3) { + xoverlay = True; + } + } + + return xoverlay; +} + +static jboolean isXCompositeDisplay(Display *display, int screenNumber) { + + char NET_WM_CM_Sn[25]; + snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber); + + Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0); + Window owner = XGetSelectionOwner(display, managerSelection); + + return owner != 0; +} static XImage *getWindowImage(Display * display, Window window, int32_t x, int32_t y, @@ -211,7 +278,7 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, jint jheight, jint scale, jintArray pixelArray, - jboolean isGtkSupported) { + jboolean useGtk) { XImage *image; jint *ary; /* Array of jints for sending pixel values back * to parent process. @@ -238,6 +305,14 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); + if (!useGtk) { + if (hasXCompositeOverlayExtension(awt_display) && + isXCompositeDisplay(awt_display, adata->awt_visInfo.screen)) + { + rootWindow = compositeGetOverlayWindow(awt_display, rootWindow); + } + } + if (!XGetWindowAttributes(awt_display, rootWindow, &attr) || sx + swidth <= attr.x || attr.x + attr.width <= sx @@ -262,7 +337,7 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env, int index; - if (isGtkSupported) { + if (useGtk) { gtk->gdk_threads_enter(); gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width, height, jwidth, dx, dy, scale); @@ -454,3 +529,8 @@ Java_sun_awt_X11_XRobotPeer_mouseWheelImpl (JNIEnv *env, AWT_UNLOCK(); } + +JNIEXPORT void JNICALL +Java_sun_awt_X11_XRobotPeer_loadNativeLibraries (JNIEnv *env, jclass cls) { + initXCompositeFunctions(); +} From bc3d4d72acfae0d0d64f1e3a3070d82bc883bdb5 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 12 Jul 2016 14:13:48 +0300 Subject: [PATCH 20/80] 8159374: Taskbar.setIconBadge() spec omits mention of exception for ICON_BADGE_TEXT feature Reviewed-by: alexsch, ssadetsky --- jdk/src/java.desktop/share/classes/java/awt/Taskbar.java | 3 ++- .../java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java index a0660ac00d5..393d8a32ba2 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Taskbar.java @@ -364,7 +364,8 @@ public class Taskbar { * @throws SecurityException if a security manager exists and it denies the * {@code AWTPermission("showWindowWithoutWarningBanner")} permission. * @throws UnsupportedOperationException if the current platform - * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} feature + * does not support the {@link Taskbar.Feature#ICON_BADGE_NUMBER} + * or {@link Taskbar.Feature#ICON_BADGE_TEXT} feature */ public void setIconBadge(final String badge) { checkAWTPermission(); diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java index 58b9559652a..8d06f1684df 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java @@ -107,6 +107,8 @@ final class XTaskbarPeer implements TaskbarPeer { val = Long.parseLong(badge); visible = true; } catch (NumberFormatException e) { + throw new UnsupportedOperationException("The " + Feature.ICON_BADGE_TEXT + + " feature is not supported on the current platform!"); } } setBadge(val, visible); From d84f5adf246220280bd32d0f53670ec8a292dc32 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 12 Jul 2016 18:47:57 +0300 Subject: [PATCH 21/80] 8161003: GPL header additional "s" in "thats" - not swapped in licensee bundles Reviewed-by: alexsch --- jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h index 5baffd8e444..0a574615d10 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h @@ -11,7 +11,7 @@ * 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 thats + * 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 From b15c691620c7d2a0dae16ab7d06378d018db63ee Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Wed, 13 Jul 2016 10:50:58 +0300 Subject: [PATCH 22/80] 8159460: On Ubuntu Unity, problem with java/awt/Window/FindOwner/FindOwnerTest Reviewed-by: azvegint --- .../classes/sun/awt/X11/XDecoratedPeer.java | 19 +++++++++++++++++-- .../unix/classes/sun/awt/X11/XWM.java | 13 +++++++++++-- .../awt/Window/FindOwner/FindOwnerTest.html | 4 ++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java index 74ee97f4f89..f4595b0eb8b 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -1010,7 +1010,22 @@ abstract class XDecoratedPeer extends XWindowPeer { if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { focusLog.fine("WM_TAKE_FOCUS on {0}", this); } - requestWindowFocus(cl.get_data(1), true); + + if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) { + // JDK-8159460 + Window focusedWindow = XKeyboardFocusManagerPeer.getInstance() + .getCurrentFocusedWindow(); + Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); + if (activeWindow != target) { + requestWindowFocus(cl.get_data(1), true); + } else { + WindowEvent we = new WindowEvent(focusedWindow, + WindowEvent.WINDOW_GAINED_FOCUS); + sendEvent(we); + } + } else { + requestWindowFocus(cl.get_data(1), true); + } } /** diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java index 5ece4e86e59..b227b5395cb 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -104,7 +104,8 @@ final class XWM COMPIZ_WM = 12, LG3D_WM = 13, CWM_WM = 14, - MUTTER_WM = 15; + MUTTER_WM = 15, + UNITY_COMPIZ_WM = 16; public String toString() { switch (WMID) { case NO_WM: @@ -129,6 +130,8 @@ final class XWM return "Metacity"; case COMPIZ_WM: return "Compiz"; + case UNITY_COMPIZ_WM: + return "Unity Compiz"; case LG3D_WM: return "LookingGlass"; case CWM_WM: @@ -572,6 +575,10 @@ final class XWM return isNetWMName("compiz"); } + static boolean isUnityCompiz() { + return isNetWMName("Compiz"); + } + static boolean isLookingGlass() { return isNetWMName("LG3D"); } @@ -790,6 +797,8 @@ final class XWM awt_wmgr = CWM_WM; } else if (doIsIceWM && isIceWM()) { awt_wmgr = XWM.ICE_WM; + } else if (isUnityCompiz()) { + awt_wmgr = XWM.UNITY_COMPIZ_WM; } /* * We don't check for legacy WM when we already know that WM diff --git a/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html index f022dc470d1..38846d9285f 100644 --- a/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html +++ b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.html @@ -1,5 +1,5 @@