X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b46b1d59d6f69ad80dcf5955375578a6504d100a..0d19936d71032ba7658616faed3b63d4c930e5b4:/src/dfb/evtloop.cpp?ds=sidebyside diff --git a/src/dfb/evtloop.cpp b/src/dfb/evtloop.cpp index 7c8f30ea80..7f7807ac72 100644 --- a/src/dfb/evtloop.cpp +++ b/src/dfb/evtloop.cpp @@ -27,11 +27,11 @@ #include "wx/thread.h" #include "wx/generic/private/timer.h" -#include "wx/private/selectdispatcher.h" +#include "wx/private/fdiodispatcher.h" #include "wx/dfb/private.h" #include "wx/nonownedwnd.h" -#define TRACE_EVENTS _T("events") +#define TRACE_EVENTS "events" // =========================================================================== // implementation @@ -76,25 +76,35 @@ wxIDirectFBEventBufferPtr wxGUIEventLoop::GetDirectFBEventBuffer() bool wxGUIEventLoop::Pending() const { - wxCHECK_MSG( ms_buffer, false, _T("invalid event buffer") ); + wxCHECK_MSG( ms_buffer, false, "invalid event buffer" ); return ms_buffer->HasEvent(); } bool wxGUIEventLoop::Dispatch() { - wxCHECK_MSG( ms_buffer, false, _T("invalid event buffer") ); - // NB: we don't block indefinitely waiting for an event, but instead // time out after a brief period in order to make sure that // OnNextIteration() will be called frequently enough + // + // TODO: remove this hack, instead use CreateFileDescriptor() to properly + // multiplex GUI and socket input const int TIMEOUT = 100; + // treat time out (-1 return value) as normal successful return so that + // OnNextIteration() is called + return !!DispatchTimeout(TIMEOUT); +} + +int wxGUIEventLoop::DispatchTimeout(unsigned long timeout) +{ + wxCHECK_MSG( ms_buffer, 0, "invalid event buffer" ); + // release the GUI mutex so that other threads have a chance to post // events: wxMutexGuiLeave(); - bool rv = ms_buffer->WaitForEventWithTimeout(0, TIMEOUT); + bool rv = ms_buffer->WaitForEventWithTimeout(0, timeout); // and acquire it back before calling any event handlers: wxMutexGuiEnter(); @@ -112,9 +122,7 @@ bool wxGUIEventLoop::Dispatch() } case DFB_TIMEOUT: - // timed out, pretend we processed an event so that - // OnNextIteration is called - break; + return -1; default: // don't terminate the loop due to errors (they were reported @@ -123,12 +131,12 @@ bool wxGUIEventLoop::Dispatch() } } - return true; + return 1; } void wxGUIEventLoop::WakeUp() { - wxCHECK_RET( ms_buffer, _T("invalid event buffer") ); + wxCHECK_RET( ms_buffer, "invalid event buffer" ); ms_buffer->WakeUp(); } @@ -141,7 +149,7 @@ void wxGUIEventLoop::OnNextIteration() #if wxUSE_SOCKETS // handle any pending socket events: - wxSelectDispatcher::DispatchPending(); + wxFDIODispatcher::DispatchPending(); #endif } @@ -179,7 +187,7 @@ void wxGUIEventLoop::HandleDFBEvent(const wxDFBEvent& event) #endif { wxLogTrace(TRACE_EVENTS, - _T("ignoring event of unsupported class %i"), + "ignoring event of unsupported class %i", (int)event.GetClass()); } }