mirror of
https://github.com/macports/macports-ports.git
synced 2026-07-12 18:20:25 -07:00
67 lines
2.1 KiB
Diff
67 lines
2.1 KiB
Diff
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 <AvailabilityMacros.h>
|
|
+
|
|
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
|
|
#include <Foundation/NSProcessInfo.h>
|
|
+#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
|
|
+#include <cstdlib>
|
|
+#include <IOKit/pwr_mgt/IOPMLib.h>
|
|
+#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<NSObject> 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
|
|
}
|
|
|
|
|