- s_inReceiveEvent = true ;
- OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ;
- s_inReceiveEvent = false ;
- if ( status == eventLoopTimedOutErr )
- {
- if ( wxTheApp->ProcessIdle() )
- sleepTime = kEventDurationNoWait ;
- else
- {
-#if wxUSE_THREADS
- if (g_numberOfThreads)
- {
- sleepTime = kEventDurationNoWait;
- }
- else
-#endif // wxUSE_THREADS
- {
- sleepTime = kEventDurationSecond;
- }
- }
- }
- else if ( status == eventLoopQuitErr )
- {
- // according to QA1061 this may also occur when a WakeUp Process
- // is executed
- }
- else
- {
- MacHandleOneEvent( theEvent ) ;
- ReleaseEvent(theEvent);
- sleepTime = kEventDurationNoWait ;
- }
-#else
- EventRecord event ;
-
- EventMask eventMask = everyEvent ;
-
- if (WaitNextEvent(eventMask, &event, sleepTime, (RgnHandle) s_macCursorRgn))
- {
- MacHandleModifierEvents( &event ) ;
- MacHandleOneEvent( &event );
- }
- else
- {
- MacHandleModifierEvents( &event ) ;
- // idlers
- WindowPtr window = ::FrontWindow() ;
- if ( window )
- ::IdleControls( window ) ;
-
- if ( wxTheApp->ProcessIdle() )
- sleepTime = kEventDurationNoWait;
- else
- {
-#if wxUSE_THREADS
- if (g_numberOfThreads)
- {
- sleepTime = kEventDurationNoWait;
- }
- else
-#endif // wxUSE_THREADS
- {
- sleepTime = kEventDurationSecond;
- }
- }
- }
- if ( event.what != kHighLevelEvent )
- SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
-#endif
- // repeaters
-
- DeletePendingObjects() ;
- wxMacProcessNotifierAndPendingEvents() ;
-}
-
-/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
-{
- // Override to process unhandled events as you please
-}
-
-void wxApp::MacHandleOneEvent( WXEVENTREF evr )
-{
-#if TARGET_CARBON
- EventTargetRef theTarget;
- theTarget = GetEventDispatcherTarget();
- m_macCurrentEvent = evr ;
- OSStatus status = SendEventToEventTarget ((EventRef) evr , theTarget);
- if(status == eventNotHandledErr)
- {
- MacHandleUnhandledEvent(evr);
- }
-#else
- EventRecord* ev = (EventRecord*) evr ;
- m_macCurrentEvent = ev ;
-
- wxApp::sm_lastMessageTime = ev->when ;
-
- switch (ev->what)
- {
- case mouseDown:
- MacHandleMouseDownEvent( ev ) ;
- if ( ev->modifiers & controlKey )
- s_lastMouseDown = 2;
- else
- s_lastMouseDown = 1;
- break;
- case mouseUp:
- if ( s_lastMouseDown == 2 )
- {
- ev->modifiers |= controlKey ;
- }
- else
- {
- ev->modifiers &= ~controlKey ;
- }
- MacHandleMouseUpEvent( ev ) ;
- s_lastMouseDown = 0;
- break;
- case activateEvt:
- MacHandleActivateEvent( ev ) ;
- break;
- case updateEvt:
- // In embedded mode we first let the UnhandledEvent function
- // try to handle the update event. If we handle it ourselves
- // first and then pass it on, the host's windows won't update.
- MacHandleUnhandledEvent(ev);
- MacHandleUpdateEvent( ev ) ;
- break;
- case keyDown:
- case autoKey:
- MacHandleKeyDownEvent( ev ) ;
- break;
- case keyUp:
- MacHandleKeyUpEvent( ev ) ;