# HG changeset patch # User mhalder # Date 1467890257 -19800 # Node ID 85dfe553dd9cd4b70d126857b9a534d9bb3d05ef # Parent 9c7500fae20ae106bf9be7c09a72037b4d3f8e05 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 diff -r 9c7500fae20a -r 85dfe553dd9c jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m Wed Jul 06 21:07:35 2016 +0530 +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m Thu Jul 07 16:47:37 2016 +0530 @@ -278,6 +278,16 @@ 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, //kCGSFlagsMaskAppleRightAlternateKey, @@ -295,16 +305,6 @@ 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 @@ }; static BOOL leftAltKeyPressed; +static BOOL altGRPressed = NO; /* * Almost all unicode characters just go from NS to Java with no translation. @@ -559,20 +560,28 @@ */ 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 -r 9c7500fae20a -r 85dfe553dd9c jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m Wed Jul 06 21:07:35 2016 +0530 +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m Thu Jul 07 16:47:37 2016 +0530 @@ -261,27 +261,10 @@ { 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); } }