We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4020 - X11 SDL2 wakes monitor and prevents standby
Summary: X11 SDL2 wakes monitor and prevents standby
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: don't know
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-02 02:05 UTC by captain.gxj
Modified: 2018-01-02 11:25 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description captain.gxj 2018-01-02 02:05:08 UTC
Calling SDL_Init(SDL_INIT_VIDEO) causes monitor/screen to wake up from standby and further prevents monitor from sleeping. (Such as when at lock screen monitor will continuously cycle on and off)

I can replicate this by starting an SDL app on a timer and using the command "xset dpms force off" to enter monitor standby; the monitor then wakes up the same time the SDL application is launched.
Comment 1 Ryan C. Gordon 2018-01-02 06:50:27 UTC
This is intentional; SDL turns off the screensaver (which likely causes this wakeup on X11) by default. Otherwise, movie players where someone is watching the screen but not interacting with the keyboard/mouse will have to fight with the screen turning off, as will games played with a joystick and not the usual input devices that X11 treats as "activity."

If you don't want your app to wake up the screen like this, you can call this before SDL_Init()...

SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");

(SDL_EnableScreenSaver() also works after SDL_Init() is done, but we've probably woke the screen by then.)

If it's not your program, you can export this environment variable to force that hint for any SDL-based program:

export SDL_VIDEO_ALLOW_SCREENSAVER=1

--ryan.
Comment 2 captain.gxj 2018-01-02 11:25:43 UTC
(In reply to Ryan C. Gordon from comment #1)

Thanks for that, this solves my issue.

So it seems like it's a complication for any Linux application on X11 wanting to prevent standby and the user wanting to lock the screen. Seems to work as expected under Wayland so I suppose its not a long term problem.