Implemented wxPOWER_RESOURCE_SCREEN for OS X versions < 10.9

This commit is contained in:
Tobias Taschner
2015-07-22 14:36:26 +02:00
parent 328743bf2d
commit 64308117e8
2 changed files with 8 additions and 3 deletions

View File

@@ -106,8 +106,7 @@ wxEventType wxEVT_POWER_RESUME;
powering off the screen and Acquire() method can be used to do this. powering off the screen and Acquire() method can be used to do this.
Notice that currently this functionality is only implemented for MSW and Notice that currently this functionality is only implemented for MSW and
OS X and on the latter only ::wxPOWER_RESOURCE_SYSTEM is supported for OS X.
versions earlier than 10.9.
If possible, use wxPowerResourceBlocker class to ensure that Release() is If possible, use wxPowerResourceBlocker class to ensure that Release() is
called instead of calling it manually. called instead of calling it manually.

View File

@@ -60,10 +60,16 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason)
#endif #endif
if ( !g_pmAssertionID ) if ( !g_pmAssertionID )
{ {
CFStringRef assertType;
if ( kind == wxPOWER_RESOURCE_SCREEN )
assertType = kIOPMAssertionTypeNoDisplaySleep;
else
assertType = kIOPMAssertionTypeNoIdleSleep;
// Use power manager API for < 10.9 systems // Use power manager API for < 10.9 systems
IOReturn success = IOPMAssertionCreateWithName IOReturn success = IOPMAssertionCreateWithName
( (
kIOPMAssertionTypeNoIdleSleep, assertType,
kIOPMAssertionLevelOn, kIOPMAssertionLevelOn,
cfreason, cfreason,
&g_pmAssertionID &g_pmAssertionID