changeset 5633:c9fb7c0e371f

2223196: [macosx] Situation when KeyEventDispatcher doesn't work on AWT but does on Swing Reviewed-by: art, ant
author leonidr
date Wed, 16 Jan 2013 04:34:29 +0400
parents f7aad97a8066
children 5d94285533ae b27c16f81b65
files src/macosx/classes/sun/lwawt/LWWindowPeer.java
diffstat 1 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Tue Jan 15 10:37:49 2013 +0000
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Wed Jan 16 04:34:29 2013 +0400
@@ -910,20 +910,16 @@
     public void dispatchKeyEvent(int id, long when, int modifiers,
                                  int keyCode, char keyChar, int keyLocation)
     {
-        KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
+        LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
         Component focusOwner = kfmPeer.getCurrentFocusOwner();
 
-        // Null focus owner may receive key event when
-        // application hides the focused window upon ESC press
-        // (AWT transfers/clears the focus owner) and pending ESC release
-        // may come to already hidden window. This check eliminates NPE.
-        if (focusOwner != null) {
-            KeyEvent event =
-                new KeyEvent(focusOwner, id, when, modifiers,
-                             keyCode, keyChar, keyLocation);
-            LWComponentPeer peer = (LWComponentPeer)focusOwner.getPeer();
-            peer.postEvent(event);
+        if (focusOwner == null) {
+            focusOwner = kfmPeer.getCurrentFocusedWindow();
+            if (focusOwner == null) {
+                focusOwner = this.getTarget();
+            }
         }
+        postEvent(new KeyEvent(focusOwner, id, when, modifiers, keyCode, keyChar, keyLocation));
     }