8151136: [macosx] According to the description, the case is failed

Reviewed-by: ssadetsky, aniyogi
This commit is contained in:
Manajit Halder 2016-04-27 13:09:58 +03:00
parent 5874c48796
commit eb3750d326
2 changed files with 30 additions and 11 deletions

View File

@ -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,11 +282,19 @@ const nsKeyToJavaModifierTable[] =
//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,
@ -310,6 +318,8 @@ const nsKeyToJavaModifierTable[] =
{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 @@ NsKeyModifiersToJavaKeyInfo(NSUInteger nsFlags, unsigned short eventKeyCode,
// *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 @@ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods)
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;
}
}

View File

@ -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 @@ public class AltGraphModifierTest {
"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 @@ public class AltGraphModifierTest {
"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 class AltGraphModifierTest {
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) {