]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxEventLoop so it does not sleep 20 msec between events when threads
authorMattia Barbon <mbarbon@cpan.org>
Fri, 14 Feb 2003 20:41:57 +0000 (20:41 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Fri, 14 Feb 2003 20:41:57 +0000 (20:41 +0000)
are anabled. Now the ode should be equivalent to the 2.4 event loop.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/motif/evtloop.cpp

index 59207e7d8d27de18512378d08f40b86c2ec38342..0c68418f27cd9d4cffc6bc131760f1841cc7e4dc 100644 (file)
@@ -173,7 +173,7 @@ bool wxEventLoop::Dispatch()
 #else
      XtAppProcessEvent( context, XtIMTimer|XtIMAlternateInput|XtIMSignal );
 #endif
-   
+
     return m_impl ? m_impl->GetKeepGoing() : true;
 }
 
@@ -345,17 +345,27 @@ bool CheckForKeyUp(XEvent* event)
 
 bool wxDoEventLoopIteration( wxEventLoop& evtLoop )
 {
+    bool moreRequested, pendingEvents;
+
+    for(;;)
+    {
+        pendingEvents = evtLoop.Pending();
+        if( pendingEvents ) break;
+        moreRequested = ::SendIdleMessage();
+        if( !moreRequested ) break;
+    }
+
 #if wxUSE_THREADS
-    // leave the main loop to give other threads a chance to
-    // perform their GUI work
-    wxMutexGuiLeave();
-    wxUsleep(20);
-    wxMutexGuiEnter();
+    if( !pendingEvents && !moreRequested )
+    {
+        // leave the main loop to give other threads a chance to
+        // perform their GUI work
+        wxMutexGuiLeave();
+        wxUsleep(20);
+        wxMutexGuiEnter();
+    }
 #endif
 
-    while ( !evtLoop.Pending() && ::SendIdleMessage() )
-        ;
-
     if( !evtLoop.Dispatch() )
         return false;