]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/evtloop.cpp
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 IDirectFBEventBufferPtr
wxEventLoop::ms_buffer
;
43 wxEventLoop::wxEventLoop()
50 void wxEventLoop::InitBuffer()
52 IDirectFBPtr
dfb(wxTheApp
->GetDirectFBInterface());
53 DFB_CALL( dfb
->CreateEventBuffer(dfb
, &ms_buffer
) );
57 IDirectFBEventBufferPtr
wxEventLoop::GetDirectFBEventBuffer()
65 //-----------------------------------------------------------------------------
66 // events dispatch and loop handling
67 //-----------------------------------------------------------------------------
69 bool wxEventLoop::Pending() const
71 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
73 // returns DFB_OK if there is >=1 event, DFB_BUFFER_EMPTY otherwise
74 return ms_buffer
->HasEvent(ms_buffer
) == DFB_OK
;
77 bool wxEventLoop::Dispatch()
79 wxCHECK_MSG( ms_buffer
, false, _T("invalid event buffer") );
81 // NB: we don't block indefinitely waiting for an event, but instead
82 // time out after a brief period in order to make sure that
83 // OnNextIteration() will be called frequently enough
85 // FIXME: call NotifyTimers() from here (and loop) instead?
86 const int TIMEOUT
= 100;
88 DFBResult ret
= ms_buffer
->WaitForEventWithTimeout(ms_buffer
, 0, TIMEOUT
);
95 ms_buffer
->GetEvent(ms_buffer
, &e
);
101 // timed out, pretend we processed an event so that OnNextIteration
106 // report any errors, but don't terminate the loop due to them
107 wxDfbCheckReturn(ret
);
114 void wxEventLoop::WakeUp()
116 wxCHECK_RET( ms_buffer
, _T("invalid event buffer") );
118 DFB_CALL( ms_buffer
->WakeUp(ms_buffer
) );
121 void wxEventLoop::OnNextIteration()
124 // see the comment in Dispatch
125 wxTimer::NotifyTimers();
129 #warning "FIXME: cleanup wxEventLoop::ms_buffer before exiting"
132 //-----------------------------------------------------------------------------
133 // DirectFB -> wxWidgets events translation
134 //-----------------------------------------------------------------------------
136 void wxEventLoop::HandleDFBEvent(const wxDFBEvent
& event
)
138 switch ( event
.GetClass() )
142 wxDFBWindowEvent
winevent(((const DFBEvent
&)event
).window
);
143 wxTopLevelWindowDFB::HandleDFBWindowEvent(winevent
);
150 #if wxCHECK_DFB_VERSION(0,9,23)
154 wxLogTrace(TRACE_EVENTS
,
155 _T("ignoring event of unsupported class %i"),
156 (int)event
.GetClass());