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/private/socketevtdispatch.h"
30 #include "wx/dfb/private.h"
32 #define TRACE_EVENTS _T("events")
34 // ===========================================================================
36 // ===========================================================================
38 //-----------------------------------------------------------------------------
39 // wxEventLoop initialization
40 //-----------------------------------------------------------------------------
42 wxIDirectFBEventBufferPtr
wxEventLoop::ms_buffer
;
44 wxEventLoop::wxEventLoop()
51 void wxEventLoop::InitBuffer()
53 ms_buffer
= wxIDirectFB::Get()->CreateEventBuffer();
57 void wxEventLoop::CleanUp()
63 wxIDirectFBEventBufferPtr
wxEventLoop::GetDirectFBEventBuffer()
71 //-----------------------------------------------------------------------------
72 // events dispatch and loop handling
73 //-----------------------------------------------------------------------------
75 bool wxEventLoop::Pending() const
77 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
79 return ms_buffer
->HasEvent();
82 bool wxEventLoop::Dispatch()
84 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
86 // NB: we don't block indefinitely waiting for an event, but instead
87 // time out after a brief period in order to make sure that
88 // OnNextIteration() will be called frequently enough
89 const int TIMEOUT
= 100;
91 if ( ms_buffer
->WaitForEventWithTimeout(0, TIMEOUT
) )
93 switch ( ms_buffer
->GetLastResult() )
98 ms_buffer
->GetEvent(e
);
104 // timed out, pretend we processed an event so that
105 // OnNextIteration is called
109 // don't terminate the loop due to errors (they were reported
110 // already by ms_buffer)
118 void wxEventLoop::WakeUp()
120 wxCHECK_RET( ms_buffer
, _T("invalid event buffer") );
125 void wxEventLoop::OnNextIteration()
128 wxTimer::NotifyTimers();
132 // handle any pending socket events:
133 wxSocketEventDispatcher::Get().RunLoop();
137 void wxEventLoop::Yield()
139 // process all pending events:
143 // handle timers, sockets etc.
148 //-----------------------------------------------------------------------------
149 // DirectFB -> wxWidgets events translation
150 //-----------------------------------------------------------------------------
152 void wxEventLoop::HandleDFBEvent(const wxDFBEvent
& event
)
154 switch ( event
.GetClass() )
158 wxDFBWindowEvent
winevent(((const DFBEvent
&)event
).window
);
159 wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent
);
166 #if wxCHECK_DFB_VERSION(0,9,23)
170 wxLogTrace(TRACE_EVENTS
,
171 _T("ignoring event of unsupported class %i"),
172 (int)event
.GetClass());