[SDL] SDL tampers with display power settings on the sly

Erik esigra at gmail.com
Tue Feb 26 05:25:09 PST 2008


Sam Lantinga skrev:
>> So the solution would be something like this: Each time the application 
>> updates the display with a new animation frame, it marks that update 
>> with a special flag, indicating that this is the kind of thing that the 
>> user may be watching even though he has not interacted with the system
>> for a while. The X server then resets the screensaver countdown.
>>     
> That's a great idea. :)
> Is there a way to pretend to the X server that there has been user input?
>   

I could try to bring it up on some Xorg mailing list and see what they 
say. But note that the X server has to know the difference between real 
and fake input events. Both should reset the screensaver countdown. But 
for security reasons, only real input events may reset the session 
locking countdown.


> The feature was added because there are two cases where X will trigger the
> screen saver even though you're still interacting with the application:
> 1. Using non-keyboard/mouse input (e.g. gamepads)
>   
While the X server is active, all input, including gamepads, must go 
through the X server. Not only so that it can handle the screensaver 
correctly, but also so that it can send the events to the correct (the 
currently active) client.

> 2. Using fullscreen input (DGA)
> In both of these cases the input is bypassing X11's normal input path and
> the screensaver kicks on.
When the X server is not handling the input it should obviously not 
handle the screesaver either, since that feature depends on the input 
handling. So it seems like the X server is trying to do something, that 
it can not possibly do right. Therefore it fails.


> In your case, you can simply set the environment variable either globally
> as a user, or in specific applications using putenv(), and it'll solve
> the problem for you.
>   
I added SDL_VIDEO_ALLOW_SCREENSAVER=1 to ~/.bashrc and added the 
following line to an application, before SDL_Init:

setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);

(All non-joystick-games should do the same.) I also added aliases for all other SDL applications (alias appname="SDL_VIDEO_ALLOW_SCREENSAVER=1 appname"). (If I had had any menu entries or panel buttons for SDL programs, I would have done that for them as well.)




More information about the SDL mailing list