From 64308117e830e50ba4ab062ece9ab3196f305914 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Wed, 22 Jul 2015 14:36:26 +0200 Subject: [PATCH] Implemented wxPOWER_RESOURCE_SCREEN for OS X versions < 10.9 --- interface/wx/power.h | 3 +-- src/osx/cocoa/power.mm | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/interface/wx/power.h b/interface/wx/power.h index 95638c75bb..375234568e 100644 --- a/interface/wx/power.h +++ b/interface/wx/power.h @@ -106,8 +106,7 @@ wxEventType wxEVT_POWER_RESUME; powering off the screen and Acquire() method can be used to do this. Notice that currently this functionality is only implemented for MSW and - OS X and on the latter only ::wxPOWER_RESOURCE_SYSTEM is supported for - versions earlier than 10.9. + OS X. If possible, use wxPowerResourceBlocker class to ensure that Release() is called instead of calling it manually. diff --git a/src/osx/cocoa/power.mm b/src/osx/cocoa/power.mm index 1b2d6d7251..c3099723d2 100644 --- a/src/osx/cocoa/power.mm +++ b/src/osx/cocoa/power.mm @@ -60,10 +60,16 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason) #endif if ( !g_pmAssertionID ) { + CFStringRef assertType; + if ( kind == wxPOWER_RESOURCE_SCREEN ) + assertType = kIOPMAssertionTypeNoDisplaySleep; + else + assertType = kIOPMAssertionTypeNoIdleSleep; + // Use power manager API for < 10.9 systems IOReturn success = IOPMAssertionCreateWithName ( - kIOPMAssertionTypeNoIdleSleep, + assertType, kIOPMAssertionLevelOn, cfreason, &g_pmAssertionID