8151136: [macosx] According to the description, the case is failed
authormhalder
Wed, 27 Apr 2016 13:09:58 +0300
changeset 38385 218b99b653c4
parent 38384 05e90f2c9ab8
child 38386 d7e7d592d396
8151136: [macosx] According to the description, the case is failed Reviewed-by: ssadetsky, aniyogi
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m
jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Wed Apr 27 12:08:37 2016 +0400
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m	Wed Apr 27 13:09:58 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -282,12 +282,20 @@
         //kCGSFlagsMaskAppleLeftAlternateKey,
         //kCGSFlagsMaskAppleRightAlternateKey,
         58,
-        61,
+        0,
         java_awt_event_InputEvent_ALT_DOWN_MASK,
         java_awt_event_InputEvent_ALT_MASK,
         java_awt_event_KeyEvent_VK_ALT
     },
     {
+        NSAlternateKeyMask,
+        0,
+        61,
+        java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK,
+        java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK,
+        java_awt_event_KeyEvent_VK_ALT
+    },
+    {
         NSCommandKeyMask,
         //kCGSFlagsMaskAppleLeftCommandKey,
         //kCGSFlagsMaskAppleRightCommandKey,
@@ -310,6 +318,8 @@
     {0, 0, 0, 0, 0, 0}
 };
 
+static BOOL leftAltKeyPressed;
+
 /*
  * Almost all unicode characters just go from NS to Java with no translation.
  *  For the few exceptions, we handle it here with this small table.
@@ -523,13 +533,17 @@
             //    *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
             //}
             if (eventKeyCode == cur->leftKeyCode) {
+                leftAltKeyPressed = YES;
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
             } else if (eventKeyCode == cur->rightKeyCode) {
                 *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT;
+            } else if (cur->nsMask == NSAlternateKeyMask) {
+                leftAltKeyPressed = NO;
+                continue;
             }
             *javaKeyType = (cur->nsMask & nsFlags) ?
-                java_awt_event_KeyEvent_KEY_PRESSED :
-                java_awt_event_KeyEvent_KEY_RELEASED;
+            java_awt_event_KeyEvent_KEY_PRESSED :
+            java_awt_event_KeyEvent_KEY_RELEASED;
             break;
         }
     }
@@ -545,7 +559,11 @@
 
     for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
         if ((cur->nsMask & nsFlags) != 0) {
-            javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
+            javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask;
+            if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) {
+                continue;
+            }
+            break;
         }
     }
 
--- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java	Wed Apr 27 12:08:37 2016 +0400
+++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java	Wed Apr 27 13:09:58 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -50,7 +50,7 @@
                     "3. If Alt-Gr key is not present, press Ctrl+Alt keys &",
                     "   perform mouse click on the TestWindow.",
                     "4. Test will exit by itself with appropriate result.",
-                    "",
+                    " ",
                     "Linux :-",
                     "1. Please check if Alt-Gr key is present on keyboard.",
                     "2. If present, press the Alt-Gr key and perform",
@@ -63,10 +63,11 @@
                     "6. Press Right Alt Key & perform mouse click on the",
                     "   TestWindow",
                     "7. Test will exit by itself with appropriate result.",
-                    "",
+                    " ",
                     "Mac :-",
-                    "   Mac fix is under progress, & will be fixed soon.",
-                    "   Please click Fail"
+                    "1. Press Right Option key on the keyboard and mouse click",
+                    "   on the TestWindow",
+                    "3. Test will exit by itself with appropriate result.",
                 };
 
         Sysout.createDialog();
@@ -77,7 +78,7 @@
     public static void initTestWindow() {
         mainFrame = new Frame();
         mainFrame.setTitle("TestWindow");
-        mainFrame.setSize(300, 200);
+        mainFrame.setBounds(700, 10, 300, 300);
         mainFrame.addMouseListener(new MouseAdapter() {
             @Override
             public void mousePressed(MouseEvent e) {