changeset 7337:33fc8a062f90

8015454: java/awt/Focus/TypeAhead/TestFocusFreeze.java hangs with jdk8 since b56 Reviewed-by: anthony
author ant
date Wed, 12 Jun 2013 16:18:04 +0400
parents 7bba0147ab3d
children a7d943998bd3
files src/share/classes/java/awt/DefaultKeyboardFocusManager.java test/java/awt/Focus/TypeAhead/TestFocusFreeze.java
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Tue Jun 11 16:30:34 2013 +0400
+++ b/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Wed Jun 12 16:18:04 2013 +0400
@@ -285,10 +285,17 @@
         TimedWindowEvent we = (TimedWindowEvent)e;
         long time = we.getWhen();
         synchronized (this) {
-            for (KeyEvent ke: enqueuedKeyEvents) {
-                if (time >= ke.getWhen()) {
-                    SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e));
-                    return true;
+            KeyEvent ke = enqueuedKeyEvents.isEmpty() ? null : enqueuedKeyEvents.getFirst();
+            if (ke != null && time >= ke.getWhen()) {
+                TypeAheadMarker marker = typeAheadMarkers.getFirst();
+                if (marker != null) {
+                    Window toplevel = marker.untilFocused.getContainingWindow();
+                    // Check that the component awaiting focus belongs to
+                    // the current focused window. See 8015454.
+                    if (toplevel != null && toplevel.isFocused()) {
+                        SunToolkit.postEvent(AppContext.getAppContext(), new SequencedEvent(e));
+                        return true;
+                    }
                 }
             }
         }
--- a/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java	Tue Jun 11 16:30:34 2013 +0400
+++ b/test/java/awt/Focus/TypeAhead/TestFocusFreeze.java	Wed Jun 12 16:18:04 2013 +0400
@@ -132,6 +132,7 @@
     }
     protected synchronized void enqueueKeyEvents(long after, Component untilFocused) {
         super.enqueueKeyEvents(after, untilFocused);
+        robot.delay(1);
         robot.keyPress(KeyEvent.VK_SPACE);
         robot.delay(50);
         robot.keyRelease(KeyEvent.VK_SPACE);