changeset 7597:05e73d9d37a6

8028617: Dvorak keyboard mapping not honored when ctrl key pressed Reviewed-by: pchelko, anthony
author anashaty
date Fri, 30 May 2014 11:05:16 +0400
parents fcde99bd8ef9
children fbd5f93e9f5b
files src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java src/macosx/classes/sun/lwawt/macosx/CPlatformView.java src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java src/macosx/native/sun/awt/AWTView.m
diffstat 5 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Fri May 23 07:07:33 2014 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Fri May 30 11:05:16 2014 +0400
@@ -98,7 +98,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);
     }
 
     // REMIND: delete this method once 'deploy' changes for 7156194 is pushed
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Fri May 23 07:07:33 2014 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Fri May 30 11:05:16 2014 +0400
@@ -126,7 +126,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) :
@@ -154,7 +154,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/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Fri May 23 07:07:33 2014 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Fri May 30 11:05:16 2014 +0400
@@ -227,7 +227,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/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java	Fri May 23 07:07:33 2014 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java	Fri May 30 11:05:16 2014 +0400
@@ -48,12 +48,14 @@
 
     // Key event information
     private short keyCode;
+    private String characters;
     private String charactersIgnoringModifiers;
 
-    public NSEvent(int type, int modifierFlags, short keyCode, String charactersIgnoringModifiers) {
+    public 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;
     }
 
@@ -120,12 +122,16 @@
         return charactersIgnoringModifiers;
     }
 
+    public String getCharacters() {
+        return characters;
+    }
+
     @Override
     public String toString() {
         return "NSEvent[" + getType() + " ," + getModifierFlags() + " ,"
                 + getClickCount() + " ," + getButtonNumber() + " ," + getX() + " ,"
                 + getY() + " ," + getAbsX() + " ," + getAbsY()+ " ," + getKeyCode() + " ,"
-                + getCharactersIgnoringModifiers() + "]";
+                + getCharacters() + " ," + getCharactersIgnoringModifiers() + "]";
     }
 
     /*
--- a/src/macosx/native/sun/awt/AWTView.m	Fri May 23 07:07:33 2014 +0400
+++ b/src/macosx/native/sun/awt/AWTView.m	Fri May 30 11:05:16 2014 +0400
@@ -421,17 +421,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/event/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);
 
     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
     static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,