X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3c861501a451503b31c075ccb59d16b0ae01e99..b2b4f8c0ca2884f99a923d30b4b37b12c76e936b:/src/dfb/evtloop.cpp diff --git a/src/dfb/evtloop.cpp b/src/dfb/evtloop.cpp index fcfeb0b25c..2ecc94a9b4 100644 --- a/src/dfb/evtloop.cpp +++ b/src/dfb/evtloop.cpp @@ -26,6 +26,7 @@ #endif #include "wx/timer.h" +#include "wx/private/socketevtdispatch.h" #include "wx/dfb/private.h" #define TRACE_EVENTS _T("events") @@ -38,7 +39,7 @@ // wxEventLoop initialization //----------------------------------------------------------------------------- -IDirectFBEventBufferPtr wxEventLoop::ms_buffer; +wxIDirectFBEventBufferPtr wxEventLoop::ms_buffer; wxEventLoop::wxEventLoop() { @@ -49,12 +50,17 @@ wxEventLoop::wxEventLoop() /* static */ void wxEventLoop::InitBuffer() { - IDirectFBPtr dfb(wxTheApp->GetDirectFBInterface()); - DFB_CALL( dfb->CreateEventBuffer(dfb, &ms_buffer) ); + ms_buffer = wxIDirectFB::Get()->CreateEventBuffer(); } /* static */ -IDirectFBEventBufferPtr wxEventLoop::GetDirectFBEventBuffer() +void wxEventLoop::CleanUp() +{ + ms_buffer.Reset(); +} + +/* static */ +wxIDirectFBEventBufferPtr wxEventLoop::GetDirectFBEventBuffer() { if ( !ms_buffer ) InitBuffer(); @@ -70,8 +76,7 @@ bool wxEventLoop::Pending() const { wxCHECK_MSG( ms_buffer, false, _T("invalid event buffer") ); - // returns DFB_OK if there is >=1 event, DFB_BUFFER_EMPTY otherwise - return ms_buffer->HasEvent(ms_buffer) == DFB_OK; + return ms_buffer->HasEvent(); } bool wxEventLoop::Dispatch() @@ -81,31 +86,30 @@ bool wxEventLoop::Dispatch() // 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 - // - // FIXME: call NotifyTimers() from here (and loop) instead? const int TIMEOUT = 100; - DFBResult ret = ms_buffer->WaitForEventWithTimeout(ms_buffer, 0, TIMEOUT); - - switch ( ret ) + if ( ms_buffer->WaitForEventWithTimeout(0, TIMEOUT) ) { - case DFB_OK: + switch ( ms_buffer->GetLastResult() ) { - wxDFBEvent e; - ms_buffer->GetEvent(ms_buffer, &e); - HandleDFBEvent(e); - break; + case DFB_OK: + { + wxDFBEvent e; + ms_buffer->GetEvent(e); + HandleDFBEvent(e); + break; + } + + case DFB_TIMEOUT: + // timed out, pretend we processed an event so that + // OnNextIteration is called + break; + + default: + // don't terminate the loop due to errors (they were reported + // already by ms_buffer) + break; } - - case DFB_TIMEOUT: - // timed out, pretend we processed an event so that OnNextIteration - // is called - break; - - default: - // report any errors, but don't terminate the loop due to them - wxDfbCheckReturn(ret); - break; } return true; @@ -115,18 +119,30 @@ void wxEventLoop::WakeUp() { wxCHECK_RET( ms_buffer, _T("invalid event buffer") ); - DFB_CALL( ms_buffer->WakeUp(ms_buffer) ); + ms_buffer->WakeUp(); } void wxEventLoop::OnNextIteration() { #if wxUSE_TIMER - // see the comment in Dispatch wxTimer::NotifyTimers(); #endif + +#if wxUSE_SOCKETS + // handle any pending socket events: + wxSocketEventDispatcher::Get().RunLoop(); +#endif } -#warning "FIXME: cleanup wxEventLoop::ms_buffer before exiting" +void wxEventLoop::Yield() +{ + // process all pending events: + while ( Pending() ) + Dispatch(); + + // handle timers, sockets etc. + OnNextIteration(); +} //----------------------------------------------------------------------------- @@ -147,7 +163,9 @@ void wxEventLoop::HandleDFBEvent(const wxDFBEvent& event) case DFEC_NONE: case DFEC_INPUT: case DFEC_USER: +#if wxCHECK_DFB_VERSION(0,9,23) case DFEC_UNIVERSAL: +#endif { wxLogTrace(TRACE_EVENTS, _T("ignoring event of unsupported class %i"),