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
90 // FIXME: call NotifyTimers() and wxSocketEventDispatcher::RunLoop() from here
91 // (and loop) instead?
92 const int TIMEOUT
= 100;
94 if ( ms_buffer
->WaitForEventWithTimeout(0, TIMEOUT
) )
96 switch ( ms_buffer
->GetLastResult() )
101 ms_buffer
->GetEvent(e
);
107 // timed out, pretend we processed an event so that
108 // OnNextIteration is called
112 // don't terminate the loop due to errors (they were reported
113 // already by ms_buffer)
121 void wxEventLoop::WakeUp()
123 wxCHECK_RET( ms_buffer
, _T("invalid event buffer") );
128 void wxEventLoop::OnNextIteration()
130 // see the comment in Dispatch
133 wxTimer::NotifyTimers();
137 // handle any pending socket events:
138 wxSocketEventDispatcher::Get().RunLoop();
143 //-----------------------------------------------------------------------------
144 // DirectFB -> wxWidgets events translation
145 //-----------------------------------------------------------------------------
147 void wxEventLoop::HandleDFBEvent(const wxDFBEvent
& event
)
149 switch ( event
.GetClass() )
153 wxDFBWindowEvent
winevent(((const DFBEvent
&)event
).window
);
154 wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent
);
161 #if wxCHECK_DFB_VERSION(0,9,23)
165 wxLogTrace(TRACE_EVENTS
,
166 _T("ignoring event of unsupported class %i"),
167 (int)event
.GetClass());