// wxEventLoop initialization
//-----------------------------------------------------------------------------
-IDirectFBEventBufferPtr wxEventLoop::ms_buffer;
+wxIDirectFBEventBufferPtr wxEventLoop::ms_buffer;
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();
{
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()
// 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;
{
wxCHECK_RET( ms_buffer, _T("invalid event buffer") );
- DFB_CALL( ms_buffer->WakeUp(ms_buffer) );
+ ms_buffer->WakeUp();
}
void wxEventLoop::OnNextIteration()
#endif
}
-#warning "FIXME: cleanup wxEventLoop::ms_buffer before exiting"
-
//-----------------------------------------------------------------------------
// DirectFB -> wxWidgets events translation