1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/evtloop.cpp
3 // Purpose: wxEventLoop implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
22 #include "wx/evtloop.h"
29 #include "wx/dfb/private.h"
31 #define TRACE_EVENTS _T("events")
33 // ===========================================================================
35 // ===========================================================================
37 //-----------------------------------------------------------------------------
38 // wxEventLoop initialization
39 //-----------------------------------------------------------------------------
41 wxIDirectFBEventBufferPtr
wxEventLoop::ms_buffer
;
43 wxEventLoop::wxEventLoop()
50 void wxEventLoop::InitBuffer()
52 ms_buffer
= wxIDirectFB::Get()->CreateEventBuffer();
56 wxIDirectFBEventBufferPtr
wxEventLoop::GetDirectFBEventBuffer()
64 //-----------------------------------------------------------------------------
65 // events dispatch and loop handling
66 //-----------------------------------------------------------------------------
68 bool wxEventLoop::Pending() const
70 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
72 return ms_buffer
->HasEvent();
75 bool wxEventLoop::Dispatch()
77 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
79 // NB: we don't block indefinitely waiting for an event, but instead
80 // time out after a brief period in order to make sure that
81 // OnNextIteration() will be called frequently enough
83 // FIXME: call NotifyTimers() from here (and loop) instead?
84 const int TIMEOUT
= 100;
86 if ( ms_buffer
->WaitForEventWithTimeout(0, TIMEOUT
) )
88 switch ( ms_buffer
->GetLastResult() )
93 ms_buffer
->GetEvent(e
);
99 // timed out, pretend we processed an event so that
100 // OnNextIteration is called
104 // don't terminate the loop due to errors (they were reported
105 // already by ms_buffer)
113 void wxEventLoop::WakeUp()
115 wxCHECK_RET( ms_buffer
, _T("invalid event buffer") );
120 void wxEventLoop::OnNextIteration()
123 // see the comment in Dispatch
124 wxTimer::NotifyTimers();
128 #warning "FIXME: cleanup wxEventLoop::ms_buffer before exiting"
131 //-----------------------------------------------------------------------------
132 // DirectFB -> wxWidgets events translation
133 //-----------------------------------------------------------------------------
135 void wxEventLoop::HandleDFBEvent(const wxDFBEvent
& event
)
137 switch ( event
.GetClass() )
141 wxDFBWindowEvent
winevent(((const DFBEvent
&)event
).window
);
142 wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent
);
149 #if wxCHECK_DFB_VERSION(0,9,23)
153 wxLogTrace(TRACE_EVENTS
,
154 _T("ignoring event of unsupported class %i"),
155 (int)event
.GetClass());