Screen saver/lock while in fullscreen


Hi All,

My game uses borderless fullscreen windows (GLFW v3.2). On Linux, the screen will lock while my game is running. I’ve also received reports that on OSX the screen saver kicks in during gameplay as well. According to the docs, this shouldn’t be happening as long as a fullscreen window is not iconified.

Is this a GLFW issue or is there something (such as a window hint) that I need to do? Note: my game receives controller input via SDL - not GLFW - in case that could be part of the problem.

Thank You


Note that even if you receive input via another API you should still call glfwPollEvents() regularly - if you’re not doing this it may be the root of your problem.


Adding a bit of extra information to this since I didn’t fully think through the implications of getting input through SDL whilst using GLFW for window creation.

Basically I’d not advise doing this. I don’t know the details of SDL’s message pump, but it’s likely that it could consume events needed by GLFW.


Hi @dougbinks,

Unfortunately I need to use SDL for its convenient Steam controller support (and a couple other things) and it’s too late in my project to make major changes. I do call glfwPollEvents() because I still use mouse and keyboard via GLFW.

I tested more thoroughly and I found that the screen saver is also not prevented on Windows. On Linux and Mac, screen blanking (screen sleep) is not prevented either (I still need to test with a screensaver there).

I also dug into the GLFW code a bit and I see some code on the Windows side for preventing screen saver and screen blanking (but it’s not working for me). On OSX, I didn’t find any code for preventing either. On Linux, I only found code that disables screen saver, but saw no mention of screen blanking prevention.

Not sure how to resolve this…


Hi Again,

Just leaving another brain dump here in case it’s helpful:

I tested on Windows more and dug around in the code and it turns out that having a password protected screensaver prevents screensaver suppression. I might have seen a note about this in the GLFW docs or code somewhere, but I don’t remember where.

I’m guessing many people have password lock screensavers. Testing a few random games on Steam, they all manage to keep the screen on despite the password protected screensaver.

Any ideas on how to get around this issue on Windows?


On Windows correct way to prevent screensaver/sleep/locking is to call SetThreadExecutionState function with ES_CONTINUOUS|ES_SYSTEM_REQUIRED argument.


I’ve confirmed that on my Windows 10 system adding a system sleep with a password lock screen will indeed cause full screen GLFW windows to not prevent system sleep, and that the solution from @mmozeiko works.

@Sheado since you found the issue would you like to report this to the GLFW Github issue list? If not I can report this.

In the case of OSX and Linux it would be useful to have a repro with an app which doesn’t use SDL input (a modified test/Monitors.c would likely be best). I can’t do that at the moment but will take a look at some point if someone else doesn’t beat me to it first.


Thanks @mmozeiko & @dougbinks,

Bug is reported here:


One more note:
ES_SYSTEM_REQUIRED didn’t work for me. Instead I had to use ES_DISPLAY_REQUIRED.



This might be a controversial opinion, but I wouldn’t actually expect glfw to automatically disable the screensaver, even in fullscreen mode. There should absolutely be a mechanism for doing so, but in my opinion this should be done on demand when the content requires it, e.g. when playing a video, or something that does not require user input. If the user has a system-wide screensaver enabled and leaves the computer displaying a static image without touching the keyboard or mouse for an extended period of time (we are talking several minutes, not seconds), isn’t that exactly when the screensaver should kick in?


@tombsar - I personally don’t care how the screensaver suppression is provided as long as there’s a way to do it. A suppressScreensaver() function call would be fine with me.

@dougbinks - Tested on Ubuntu by fullscreening simple.c. Result: screen sleep and screensaver were not prevented.


Linux screensaver issue reported here:


This should be fixed now on Windows. X11 fix still remaining. Thank you for reporting this!