X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9af42efda6c78093872a67180d43d5eeba261fee..9482c64466359ec7cfd201bebc3399ac4a56b4e6:/src/osx/carbon/evtloop.cpp diff --git a/src/osx/carbon/evtloop.cpp b/src/osx/carbon/evtloop.cpp index 45aad41e25..928e7f90a7 100644 --- a/src/osx/carbon/evtloop.cpp +++ b/src/osx/carbon/evtloop.cpp @@ -28,6 +28,7 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/log.h" #endif // WX_PRECOMP #include "wx/osx/private.h" @@ -48,6 +49,11 @@ void wxGUIEventLoop::WakeUp() wxMacWakeUp(); } +CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const +{ + return CFRunLoopGetCurrent(); +} + void wxGUIEventLoop::DispatchAndReleaseEvent(EventRef theEvent) { if ( wxTheApp ) @@ -88,6 +94,8 @@ bool wxGUIEventLoop::Dispatch() switch (status) { case eventLoopTimedOutErr : + // process pending wx events before sending idle events + wxTheApp->ProcessPendingEvents(); if ( wxTheApp->ProcessIdle() ) m_sleepTime = kEventDurationNoWait ; else @@ -137,3 +145,43 @@ int wxGUIEventLoop::DispatchTimeout(unsigned long timeout) } } +bool wxGUIEventLoop::YieldFor(long eventsToProcess) +{ +#if wxUSE_THREADS + // Yielding from a non-gui thread needs to bail out, otherwise we end up + // possibly sending events in the thread too. + if ( !wxThread::IsMain() ) + { + return true; + } +#endif // wxUSE_THREADS + + m_isInsideYield = true; + m_eventsToProcessInsideYield = eventsToProcess; + +#if wxUSE_LOG + // disable log flushing from here because a call to wxYield() shouldn't + // normally result in message boxes popping up &c + wxLog::Suspend(); +#endif // wxUSE_LOG + + // process all pending events: + while ( Pending() ) + Dispatch(); + + // it's necessary to call ProcessIdle() to update the frames sizes which + // might have been changed (it also will update other things set from + // OnUpdateUI() which is a nice (and desired) side effect) + while ( ProcessIdle() ) {} + + // if there are pending events, we must process them. + if (wxTheApp) + wxTheApp->ProcessPendingEvents(); + +#if wxUSE_LOG + wxLog::Resume(); +#endif // wxUSE_LOG + m_isInsideYield = false; + + return true; +}