8028617: Dvorak keyboard mapping not honored when ctrl key pressed
Reviewed-by: pchelko, anthony
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Wed May 28 15:36:10 2014 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu May 29 17:31:41 2014 +0400
@@ -97,7 +97,8 @@
public void handleKeyEvent(int eventType, int modifierFlags, String characters,
String charsIgnoringMods, boolean isRepeat, short keyCode,
boolean needsKeyTyped) {
- responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode, needsKeyTyped, isRepeat);
+ responder.handleKeyEvent(eventType, modifierFlags, characters, charsIgnoringMods,
+ keyCode, needsKeyTyped, isRepeat);
}
public void handleInputEvent(String text) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Wed May 28 15:36:10 2014 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Thu May 29 17:31:41 2014 +0400
@@ -125,7 +125,7 @@
/**
* Handles key events.
*/
- void handleKeyEvent(int eventType, int modifierFlags, String chars,
+ void handleKeyEvent(int eventType, int modifierFlags, String chars, String charsIgnoringModifiers,
short keyCode, boolean needsKeyTyped, boolean needsKeyReleased) {
boolean isFlagsChangedEvent =
isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
@@ -153,7 +153,10 @@
testChar = chars.charAt(0);
}
- int[] in = new int[] {testChar, isDeadChar ? 1 : 0, modifierFlags, keyCode};
+ char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ?
+ charsIgnoringModifiers.charAt(0) : KeyEvent.CHAR_UNDEFINED;
+
+ int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode};
int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Wed May 28 15:36:10 2014 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Thu May 29 17:31:41 2014 +0400
@@ -200,7 +200,7 @@
}
private void deliverKeyEvent(NSEvent event) {
- responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
+ responder.handleKeyEvent(event.getType(), event.getModifierFlags(), event.getCharacters(),
event.getCharactersIgnoringModifiers(), event.getKeyCode(), true, false);
}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java Wed May 28 15:36:10 2014 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/NSEvent.java Thu May 29 17:31:41 2014 +0400
@@ -47,13 +47,15 @@
// Key event information
private short keyCode;
+ private String characters;
private String charactersIgnoringModifiers;
// Called from native
- NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) {
+ NSEvent(int type, int modifierFlags, short keyCode, String characters, String charactersIgnoringModifiers) {
this.type = type;
this.modifierFlags = modifierFlags;
this.keyCode = keyCode;
+ this.characters = characters;
this.charactersIgnoringModifiers = charactersIgnoringModifiers;
}
@@ -121,12 +123,16 @@
return charactersIgnoringModifiers;
}
+ String getCharacters() {
+ return characters;
+ }
+
@Override
public String toString() {
return "NSEvent[" + getType() + " ," + getModifierFlags() + " ,"
+ getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ,"
+ getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ,"
- + getCharactersIgnoringModifiers() + "]";
+ + getCharacters() + " ," + getCharactersIgnoringModifiers() + "]";
}
/*
--- a/jdk/src/macosx/native/sun/awt/AWTView.m Wed May 28 15:36:10 2014 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTView.m Thu May 29 17:31:41 2014 +0400
@@ -440,17 +440,20 @@
JNIEnv *env = [ThreadUtilities getJNIEnv];
jstring characters = NULL;
+ jstring charactersIgnoringModifiers = NULL;
if ([event type] != NSFlagsChanged) {
characters = JNFNSToJavaString(env, [event characters]);
+ charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]);
}
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
- static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V");
+ static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V");
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
[event keyCode],
- characters);
+ characters,
+ charactersIgnoringModifiers);
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");