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 void wxEventLoop::CleanUp()
62 wxIDirectFBEventBufferPtr
wxEventLoop::GetDirectFBEventBuffer()
70 //-----------------------------------------------------------------------------
71 // events dispatch and loop handling
72 //-----------------------------------------------------------------------------
74 bool wxEventLoop::Pending() const
76 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
78 return ms_buffer
->HasEvent();
81 bool wxEventLoop::Dispatch()
83 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
85 // NB: we don't block indefinitely waiting for an event, but instead
86 // time out after a brief period in order to make sure that
87 // OnNextIteration() will be called frequently enough
89 // FIXME: call NotifyTimers() from here (and loop) instead?
90 const int TIMEOUT
= 100;
92 if ( ms_buffer
->WaitForEventWithTimeout(0, TIMEOUT
) )
94 switch ( ms_buffer
->GetLastResult() )
99 ms_buffer
->GetEvent(e
);
105 // timed out, pretend we processed an event so that
106 // OnNextIteration is called
110 // don't terminate the loop due to errors (they were reported
111 // already by ms_buffer)
119 void wxEventLoop::WakeUp()
121 wxCHECK_RET( ms_buffer
, _T("invalid event buffer") );
126 void wxEventLoop::OnNextIteration()
129 // see the comment in Dispatch
130 wxTimer::NotifyTimers();
135 //-----------------------------------------------------------------------------
136 // DirectFB -> wxWidgets events translation
137 //-----------------------------------------------------------------------------
139 void wxEventLoop::HandleDFBEvent(const wxDFBEvent
& event
)
141 switch ( event
.GetClass() )
145 wxDFBWindowEvent
winevent(((const DFBEvent
&)event
).window
);
146 wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent
);
153 #if wxCHECK_DFB_VERSION(0,9,23)
157 wxLogTrace(TRACE_EVENTS
,
158 _T("ignoring event of unsupported class %i"),
159 (int)event
.GetClass());