X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/36b960067d3b6ccbccce129e499e04a69854f827..c9ed413ab4f5673ffff00198dc6ce1397398bda4:/src/osx/carbon/app.cpp diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index af71ecc6a3..7e03354c97 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -249,18 +249,13 @@ short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU 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 ; } @@ -513,7 +508,7 @@ wxMenu* wxFindMenuFromMacCommand( const HICommand &command , wxMenuItem* &item ) GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , &refCon ) ; itemMenu = wxFindMenuFromMacMenu( command.menu.menuRef ) ; if ( itemMenu != NULL && refCon != 0) - item = ((wxMenuItemImpl*) refCon)->GetWXPeer() ; + item = (wxMenuItem*) refCon; } } #endif @@ -780,11 +775,6 @@ wxMacAssertOutputHandler(OSType WXUNUSED(componentSignature), #endif // wxDEBUG_LEVEL -extern "C" void macPostedEventCallback(void *WXUNUSED(unused)) -{ - wxTheApp->ProcessPendingEvents(); -} - bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific @@ -828,16 +818,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) 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; } @@ -866,20 +846,12 @@ bool wxApp::ProcessIdle() 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() { @@ -958,12 +930,6 @@ void wxApp::CleanUp() wxToolTip::RemoveToolTips() ; #endif - if (m_macEventPosted) - { - CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_macEventPosted, kCFRunLoopCommonModes); - m_macEventPosted = NULL; - } - DoCleanUp(); wxAppBase::CleanUp(); @@ -1071,7 +1037,6 @@ wxApp::wxApp() m_macCurrentEvent = NULL ; m_macCurrentEventHandlerCallRef = NULL ; - m_macEventPosted = NULL ; m_macPool = new wxMacAutoreleasePool(); } @@ -1117,12 +1082,10 @@ void wxApp::OnIdle(wxIdleEvent& WXUNUSED(event)) 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)) @@ -1135,10 +1098,17 @@ 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); } }