X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed5b9811866b5c4e76432ae7592d6f5f8c14bfcb..61cca9d24ee3f935f2581e3cfb894e46181290e6:/src/mac/carbon/app.cpp?ds=sidebyside diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 6d077eb60d..b30fd5576d 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -53,7 +53,7 @@ #if wxUSE_SOCKETS #ifdef __APPLE__ - #include + #include #else #include #include @@ -95,25 +95,41 @@ bool wxApp::s_macSupportPCMenuShortcuts = true ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; wxString wxApp::s_macHelpMenuTitleName = "&Help" ; +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon ) +#else pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) +#endif { wxApp* app = (wxApp*) refcon ; return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ; } +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon ) +#else pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) +#endif { wxApp* app = (wxApp*) refcon ; return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ; } +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon ) +#else pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) +#endif { wxApp* app = (wxApp*) refcon ; return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ; } +#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) +pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon ) +#else pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon ) +#endif { wxApp* app = (wxApp*) refcon ; return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; @@ -347,21 +363,22 @@ bool wxApp::Initialize() (long) wxTheApp , FALSE ) ; #else AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , - (long) wxTheApp , FALSE ) ; + (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , - (long) wxTheApp , FALSE ) ; + (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , - (long) wxTheApp , FALSE ) ; + (long) wxTheApp , FALSE ) ; AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , - (long) wxTheApp , FALSE ) ; + (long) wxTheApp , FALSE ) ; #endif #ifndef __UNIX__ // test the minimal configuration necessary + #if !TARGET_CARBON long theSystem ; - long theMachine; + long theMachine; if (Gestalt(gestaltMachineType, &theMachine) != noErr) { @@ -379,7 +396,6 @@ bool wxApp::Initialize() { error = kMacSTROldSystem ; } - #if !TARGET_CARBON else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap) { error = kMacSTRSmallSize; @@ -855,12 +871,22 @@ void wxCYield() } // Yield to other processes + +static bool gs_inYield = FALSE; + bool wxYield() { +#ifdef __WXDEBUG__ + if (gs_inYield) + wxFAIL_MSG( wxT("wxYield called recursively" ) ); +#endif + + gs_inYield = TRUE; + #if wxUSE_THREADS - YieldToAnyThread() ; + YieldToAnyThread() ; #endif - EventRecord event ; + EventRecord event ; long sleepTime = 0 ; //::GetCaretTime(); @@ -870,7 +896,19 @@ bool wxYield() } wxMacProcessNotifierAndPendingEvents() ; - return TRUE; + + gs_inYield = FALSE; + + return TRUE; +} + +// Yield to incoming messages; but fail silently if recursion is detected. +bool wxYieldIfNeeded() +{ + if (gs_inYield) + return FALSE; + + return wxYield(); } // platform specifics @@ -1447,7 +1485,11 @@ void wxApp::MacHandleOSEvent( EventRecord *ev ) case suspendResumeMessage : { bool isResuming = ev->message & resumeFlag ; +#if !TARGET_CARBON bool convertClipboard = ev->message & convertClipboardFlag ; +#else + bool convertClipboard = false; +#endif bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ; if ( isResuming ) {