1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/evtloop.mm
3 // Purpose: implementation of wxEventLoop for OS X
4 // Author: Vadim Zeitlin, Stefan Csomor
7 // RCS-ID: $Id: evtloop.cpp 54845 2008-07-30 14:52:41Z SC $
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"
32 #include "wx/evtloop.h"
34 #include "wx/osx/private.h"
36 // ============================================================================
37 // wxEventLoop implementation
38 // ============================================================================
40 wxGUIEventLoop::wxGUIEventLoop()
45 void wxGUIEventLoop::WakeUp()
47 extern void wxMacWakeUp();
52 bool wxGUIEventLoop::Pending() const
54 wxMacAutoreleasePool autoreleasepool;
55 // a pointer to the event is returned if there is one, or nil if not
56 return [[NSApplication sharedApplication]
57 nextEventMatchingMask: NSAnyEventMask
59 inMode: NSDefaultRunLoopMode
63 bool wxGUIEventLoop::Dispatch()
68 wxMacAutoreleasePool autoreleasepool;
70 if(NSEvent *event = [NSApp
71 nextEventMatchingMask:NSAnyEventMask
72 untilDate:[NSDate dateWithTimeIntervalSinceNow: m_sleepTime]
73 inMode:NSDefaultRunLoopMode
77 [NSApp sendEvent: event];
81 if ( wxTheApp->ProcessIdle() )
97 int wxGUIEventLoop::DispatchTimeout(unsigned long timeout)
99 wxMacAutoreleasePool autoreleasepool;
101 NSEvent *event = [NSApp
102 nextEventMatchingMask:NSAnyEventMask
103 untilDate:[NSDate dateWithTimeIntervalSinceNow: timeout/1000]
104 inMode:NSDefaultRunLoopMode
109 [NSApp sendEvent: event];