コード例 #1
0
DisplaySleepDisabler::DisplaySleepDisabler(const char* reason)
    : m_disableDisplaySleepAssertion(0)
{
#if !PLATFORM(IOS)
    RetainPtr<CFStringRef> reasonCF = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, reason, kCFStringEncodingUTF8));
    IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonCF.get(), &m_disableDisplaySleepAssertion);
#else
    UNUSED_PARAM(reason);
    IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &m_disableDisplaySleepAssertion);
    m_systemActivityTimer.startRepeating(systemActivityInterval);
#endif
}
コード例 #2
0
ファイル: video_output_qt.cpp プロジェクト: GiR-Zippo/bino
void video_output_qt::suspend_screensaver()
{
#if defined(Q_OS_WIN)
    /* TODO */
#elif defined(Q_OS_MAC)
# if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
    // API introduced in 10.6
    IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR ("Bino"), &_disableDisplaySleepAssertion);
# else
    // API introduced in OSX 10.5, deprecated in 10.6
    IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &_disableDisplaySleepAssertion);
# endif
#elif defined(Q_OS_UNIX)
    _widget->stop_rendering();
    if (QProcess::execute(QString("xdg-screensaver suspend ")
                + str::from(_container_widget->winId()).c_str()) != 0)
        msg::wrn(_("Cannot suspend screensaver."));
    _widget->start_rendering();
#endif
}
コード例 #3
0
ファイル: power_management.cpp プロジェクト: idgaf/FileZilla3
void CPowerManagement::DoSetBusy()
{
	if (m_busy)
		return;

	if (!COptions::Get()->GetOptionVal(OPTION_PREVENT_IDLESLEEP))
		return;

	m_busy = true;

#ifdef __WXMSW__
	SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
#elif defined(WITH_LIBDBUS)
	m_inhibitor->RequestBusy();
#elif defined(__WXMAC__)
	// >= 10.5 Required for Power Management
	#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
		IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID);
		if (success != kIOReturnSuccess)
			m_busy = false;
	#endif
#endif
}
コード例 #4
0
int main()
{    
    IOReturn                ret = kIOReturnSuccess; 
    IOPMAssertionID         assertion_id[DO_ITERATIONS] = {kIOPMNullAssertionID};
    int                     didIterations = 0;
    int                     didFork = 0;


    int i=0;
    int failureLine = 0;

    PMTestInitialize("AssertOneWithTimeout: Create an assertion, set a timeout, let it expire. Wait 10 seconds.", "com.apple.iokit.powermanagement");
    PMTestLog("Performing %d assert, settimeout, release cycles.", DO_ITERATIONS);

    for (i=0; i<DO_ITERATIONS; i++)
    {
        ret = IOPMAssertionCreate(  kIOPMAssertionTypeNoDisplaySleep, 
                                    kIOPMAssertionLevelOn, 
                                    &assertion_id[i]);

        if(kIOReturnSuccess != ret) {
            PMTestFail("Error 0x%08x from IOPMAssertionCreate()\n", ret);
            failureLine = __LINE__;
            break;
        }

        ret = IOPMAssertionSetTimeout(assertion_id[i], 5.0);

        if(kIOReturnSuccess != ret) {
            PMTestFail("Error 0x%08x from IOPMAssertionSetTimeout()\n", ret);
            failureLine = __LINE__;
            break;
        }
        
    }
    
    sleep(10);

    /* 
     * 
     * WAIT FOR ASSERTIONS TO TIMEOUT 
     *
     */

    for (i=0; i<DO_ITERATIONS; i++)
    {
        IOPMAssertionRelease(assertion_id[i]);
    }

    didIterations = i;

    PMTestLog("IOPMAssertionSetTimeout stress test: Did %d iterations, %d of which were forked children.", didIterations, didFork);
    
    if (kIOReturnSuccess != ret) {
        PMTestFail("Failure - IOReturn value 0x%08x returned at %s:%d", ret, __FILE__, failureLine);
    } else {
        PMTestPass("settimeout stress test succeeded.");
    }
    
    // TODO: Test did configd crash?

    return 0;
}