+void wxObserverCallBack(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info)
+{
+ wxCFEventLoop * eventloop = static_cast<wxCFEventLoop *>(info);
+ if ( eventloop )
+ eventloop->ObserverCallBack(observer, activity);
+}
+
+void wxCFEventLoop::ObserverCallBack(CFRunLoopObserverRef observer, int activity)
+{
+ if ( activity & kCFRunLoopBeforeTimers )
+ {
+ // process pending wx events first as they correspond to low-level events
+ // which happened before, i.e. typically pending events were queued by a
+ // previous call to Dispatch() and if we didn't process them now the next
+ // call to it might enqueue them again (as happens with e.g. socket events
+ // which would be generated as long as there is input available on socket
+ // and this input is only removed from it when pending event handlers are
+ // executed)
+
+ if ( wxTheApp )
+ wxTheApp->ProcessPendingEvents();
+ }
+
+ if ( activity & kCFRunLoopBeforeWaiting )
+ {
+ if ( ProcessIdle() )
+ {
+ WakeUp();
+ }
+ else
+ {
+#if wxUSE_THREADS
+ wxMutexGuiLeave();
+ wxMilliSleep(20);
+ wxMutexGuiEnter();
+#endif
+ }
+ }
+}
+