EventQueue.java (getCurrentEvent): Consider that system events may be handled by...
authorFernando Nasser <fnasser@redhat.com>
Mon, 19 Jan 2004 14:51:54 +0000 (14:51 +0000)
committerFernando Nasser <fnasser@gcc.gnu.org>
Mon, 19 Jan 2004 14:51:54 +0000 (14:51 +0000)
        * java/awt/EventQueue.java (getCurrentEvent): Consider that system
        events may be handled by any queue in the stack.

From-SVN: r76150

libjava/ChangeLog
libjava/java/awt/EventQueue.java

index 4a173977216f2134d6a57a72a026211e1ee7ce64..cd7d66af18b00e9dd6db3c9e5f50b3b5a99dd529 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-19  Fernando Nasser  <fnasser@redhat.com>
+
+       * java/awt/EventQueue.java (getCurrentEvent): Consider that system
+       events may be handled by any queue in the stack.
+
 2004-01-19  Kim Ho  <kho@redhat.com>
 
        * gnu/java/awt/peer/gtk/GtkFramePeer.java (getMenuBarHeight): Added
index 41dad066989b3026b6dbe6b54b109b168d8a578f..4cb0703ec6235bc5c5740b89e9c9c28579667063 100644 (file)
@@ -293,8 +293,18 @@ public class EventQueue
   public static AWTEvent getCurrentEvent()
   {
     EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); 
-    if (Thread.currentThread() != eq.dispatchThread)
-      return null;
+    Thread ct = Thread.currentThread();
+    
+    /* Find out if this thread is the dispatch thread for any of the
+       EventQueues in the chain */ 
+    while (ct != eq.dispatchThread)
+      {
+        // Try next EventQueue, if any
+        if (eq.next == null)
+           return null;  // Not an event dispatch thread
+        eq = eq.next;
+      }
+
     return eq.currentEvent;
   }