Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Screensaver



  • Hi, can someone suggest me a cross platform way (Windows, Linux, Mac) to postpone or momentary disable till the app is running the screensaver?


  • Lifetime Qt Champion

    Hi,

    Do you mean suspend your application when the screen saver starts ?



  • no no, I need to suspend the screensaver when my gui application is running.



  • Windows

    SetThreadExecutionState(ES_DISPLAY_REQUIRED);
    SetThreadExecutionState(ES_CONTINUOUS);
    

    Linux

    Display *display= XOpenDisplay(nullptr);
    if (display) {
        XResetScreenSaver(display);
        XCloseDisplay(display);
    }
    

    Mac

    IOPMAssertionID AssertionID;
    IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PianoJokeTouch"), &AssertionID);
    

Log in to reply