/[classpath]/classpath/java/awt/EventQueue.java
ViewVC logotype

Diff of /classpath/java/awt/EventQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by trebligd, Wed Jul 6 08:15:17 2005 UTC revision 1.24 by fitzsim, Mon Aug 15 18:32:38 2005 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.awt;  package java.awt;
40    
 import gnu.java.awt.ClasspathToolkit;  
   
41  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
42  import java.awt.event.InputEvent;  import java.awt.event.InputEvent;
43  import java.awt.event.InputMethodEvent;  import java.awt.event.InputMethodEvent;
# Line 78  public class EventQueue Line 76  public class EventQueue
76    private EventDispatchThread dispatchThread = new EventDispatchThread(this);    private EventDispatchThread dispatchThread = new EventDispatchThread(this);
77    private boolean shutdown = false;    private boolean shutdown = false;
78    
   private long lastNativeQueueAccess = 0;  
   private long humanLatencyThreshold = 100;  
   
79    synchronized void setShutdown (boolean b)    synchronized void setShutdown (boolean b)
80    {    {
81      shutdown = b;      shutdown = b;
# Line 94  public class EventQueue Line 89  public class EventQueue
89      // This is the exact self-shutdown condition specified in J2SE:      // This is the exact self-shutdown condition specified in J2SE:
90      // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html      // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html
91            
92      if (peekEvent() == null      // FIXME: check somewhere that the native queue is empty
93          && ((ClasspathToolkit) Toolkit.getDefaultToolkit()).nativeQueueEmpty())      if (peekEvent() == null)
94        {        {
95          Frame[] frames = Frame.getFrames();          Frame[] frames = Frame.getFrames();
96          for (int i = 0; i < frames.length; ++i)          for (int i = 0; i < frames.length; ++i)
# Line 127  public class EventQueue Line 122  public class EventQueue
122    {    {
123      if (next != null)      if (next != null)
124        return next.getNextEvent();        return next.getNextEvent();
       
     ClasspathToolkit tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit());  
     long curr = System.currentTimeMillis();  
   
     if (! tk.nativeQueueEmpty() &&  
         (curr - lastNativeQueueAccess > humanLatencyThreshold))  
       {  
         tk.iterateNativeQueue(this, false);  
         lastNativeQueueAccess = curr;  
       }  
125    
126      while (next_in == next_out)      while (next_in == next_out)
127        {        {
         // Only the EventDispatchThread associated with the top of the stack is  
         // allowed to get events from the native source; everyone else just  
         // waits on the head of the queue.  
   
128          if (isDispatchThread())          if (isDispatchThread())
129            {            {
130              // We are not allowed to return null from this method, yet it              // We are not allowed to return null from this method, yet it
# Line 158  public class EventQueue Line 139  public class EventQueue
139              if (isShutdown())              if (isShutdown())
140                throw new InterruptedException();                throw new InterruptedException();
141    
142              tk.iterateNativeQueue(this, true);              wait();
143              lastNativeQueueAccess = System.currentTimeMillis();            }
           }  
         else  
           {  
             try  
               {  
                 wait();  
               }  
             catch (InterruptedException ie)  
               {  
               }  
           }  
144        }        }
145    
146      AWTEvent res = queue[next_out];      AWTEvent res = queue[next_out];
# Line 298  public class EventQueue Line 268  public class EventQueue
268          dispatchThread.start();          dispatchThread.start();
269        }        }
270    
     // Window events might represent the closing of a window, which  
     // might cause the end of the dispatch thread's life, so we'll wake  
     // it up here to give it a chance to check for shutdown.  
   
     if (!isDispatchThread()  
         || (evt.getID() == WindowEvent.WINDOW_CLOSED)  
         || (evt.getID() == WindowEvent.WINDOW_CLOSING))  
       ((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();  
   
271      notify();      notify();
272    }    }
273    
# Line 478  public class EventQueue Line 439  public class EventQueue
439              next_in = 0;              next_in = 0;
440              next_out = 0;              next_out = 0;
441    
             ((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();  
442              setShutdown(true);              setShutdown(true);
443              dispatchThread = null;              dispatchThread = null;
444              this.notifyAll();              this.notifyAll();

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26