short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
{
- wxWindow* win = GetTopWindow() ;
- if ( win )
+ wxCloseEvent event;
+ wxTheApp->OnQueryEndSession(event);
+ if ( !event.GetVeto() )
{
- wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
- if (!win->GetEventHandler()->ProcessEvent(exitEvent))
- win->Close(true) ;
+ wxCloseEvent event;
+ wxTheApp->OnEndSession(event);
}
- else
- {
- ExitMainLoop() ;
- }
-
return noErr ;
}
#endif // wxDEBUG_LEVEL
-extern "C" void macPostedEventCallback(void *WXUNUSED(unused))
-{
- wxTheApp->ProcessPendingEvents();
-}
-
bool wxApp::Initialize(int& argc, wxChar **argv)
{
// Mac-specific
wxSetWorkingDirectory( cwd ) ;
}
- /* connect posted events to common-mode run loop so that wxPostEvent events
- are handled even while we're in the menu or on a scrollbar */
- /*
- CFRunLoopSourceContext event_posted_context = {0};
- event_posted_context.perform = macPostedEventCallback;
- m_macEventPosted = CFRunLoopSourceCreate(NULL,0,&event_posted_context);
- CFRunLoopAddSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes);
- // run loop takes ownership
- CFRelease(m_macEventPosted);
- */
return true;
}
return wxAppBase::ProcessIdle();
}
-#if wxOSX_USE_COCOA_OR_CARBON
-
int wxApp::OnRun()
{
wxMacAutoreleasePool pool;
return wxAppBase::OnRun();
}
-#else
-
-// iPhone version in utils.mm
-
-#endif
-
#if wxOSX_USE_CARBON
bool wxApp::DoInitGui()
{
wxToolTip::RemoveToolTips() ;
#endif
- if (m_macEventPosted)
- {
- CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes);
- m_macEventPosted = NULL;
- }
-
DoCleanUp();
wxAppBase::CleanUp();
m_macCurrentEvent = NULL ;
m_macCurrentEventHandlerCallRef = NULL ;
- m_macEventPosted = NULL ;
m_macPool = new wxMacAutoreleasePool();
}
void wxApp::WakeUpIdle()
{
- if (m_macEventPosted)
- {
- CFRunLoopSourceSignal(m_macEventPosted);
- }
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
- wxMacWakeUp() ;
+ if ( loop )
+ loop->WakeUp();
}
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
// user can veto the close, and therefore the end session.
void wxApp::OnQueryEndSession(wxCloseEvent& event)
{
- if (GetTopWindow())
+ if ( !wxDialog::OSXHasModalDialogsOpen() )
+ {
+ if (GetTopWindow())
+ {
+ if (!GetTopWindow()->Close(!event.CanVeto()))
+ event.Veto(true);
+ }
+ }
+ else
{
- if (!GetTopWindow()->Close(!event.CanVeto()))
- event.Veto(true);
+ event.Veto(true);
}
}