Restore power management for OS X < 10.9. This code is based on the implementation used in earlier versions of FileZilla. --- ./src/interface/power_management.cpp.orig 2020-06-18 16:06:46.000000000 +0200 +++ ./src/interface/power_management.cpp 2023-03-25 20:41:35.000000000 +0100 @@ -112,7 +112,7 @@ #ifdef __WXMSW__ return true; #endif -#if defined(__WXMAC__) +#if defined(__WXMAC__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 return true; #endif #ifdef WITH_LIBDBUS --- ./src/interface/power_management_osx.mm.orig 2020-06-04 12:18:02.000000000 +0200 +++ ./src/interface/power_management_osx.mm 2023-03-25 20:43:11.000000000 +0100 @@ -1,18 +1,48 @@ +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 #include +#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +#include +#include +#endif void const* PowerManagmentImpl_SetBusy() { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 NSActivityOptions opt = NSActivityUserInitiated | NSActivityIdleSystemSleepDisabled; id activity = [[NSProcessInfo processInfo] beginActivityWithOptions:opt reason:@"Preventing idle sleep during transfers and other operations."]; return CFBridgingRetain(activity); +#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + IOPMAssertionID assertionID; + IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &assertionID); + if (success == kIOReturnSuccess) { + IOPMAssertionID* ret = (IOPMAssertionID*)malloc(sizeof(assertionID)); + if (ret == NULL) { + return 0; + } + *ret = assertionID; + return ret; + } else { + return 0; + } +#endif } void PowerManagmentImpl_SetIdle(void const* activity) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 if (activity) { id activityId = CFBridgingRelease(activity); [[NSProcessInfo processInfo] endActivity:activityId]; } +#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + if (activity) { + IOPMAssertionID assertionID = *(IOPMAssertionID*)activity; + IOPMAssertionRelease(assertionID); + free((void*)activity); + } +#endif }