1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/evtloop.cpp
3 // Purpose: implementation of wxEventLoop for wxMac
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/evtloop.h"
33 #include "wx/osx/private.h"
35 // ============================================================================
36 // wxEventLoop implementation
37 // ============================================================================
39 wxGUIEventLoop::wxGUIEventLoop()
41 m_sleepTime
= kEventDurationNoWait
;
44 void wxGUIEventLoop::WakeUp()
46 extern void wxMacWakeUp();
51 bool wxGUIEventLoop::Pending() const
55 return ReceiveNextEvent
57 0, // we want any event at all so we don't specify neither
58 NULL
, // the number of event types nor the types themselves
60 false, // don't remove the event from queue
65 bool wxGUIEventLoop::Dispatch()
70 wxMacAutoreleasePool autoreleasepool
;
74 OSStatus status
= ReceiveNextEvent(0, NULL
, m_sleepTime
, true, &theEvent
) ;
78 case eventLoopTimedOutErr
:
79 if ( wxTheApp
->ProcessIdle() )
80 m_sleepTime
= kEventDurationNoWait
;
83 m_sleepTime
= kEventDurationSecond
;
92 case eventLoopQuitErr
:
93 // according to QA1061 this may also occur
94 // when a WakeUp Process is executed
99 wxTheApp
->MacSetCurrentEvent( theEvent
, NULL
);
101 OSStatus status
= SendEventToEventTarget(theEvent
, GetEventDispatcherTarget());
102 if (status
== eventNotHandledErr
&& wxTheApp
)
103 wxTheApp
->MacHandleUnhandledEvent(theEvent
);
105 ReleaseEvent( theEvent
);
106 m_sleepTime
= kEventDurationNoWait
;