Fix screensaver disabled unexpectedly

By default, scrcpy does not prevent the screensaver from running on the
computer unless the `--disable-screensaver` option is passed.

Otherwise, `SDL_EnableScreenSaver()` must be called explicitly, since
SDL disables the screensaver by default.

Refs <https://wiki.libsdl.org/SDL3/SDL_DisableScreenSaver>
PR #6754 <https://github.com/Genymobile/scrcpy/pull/6754>

Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
ayooh 2026-04-06 00:38:50 +08:00 committed by Romain Vimont
parent de3db42997
commit 758d0a1cc0

View file

@ -140,7 +140,7 @@ sdl_set_hints(const char *render_driver) {
}
static void
sdl_configure(bool video_playback, bool disable_screensaver) {
sdl_configure(bool disable_screensaver) {
#ifdef _WIN32
// Clean up properly on Ctrl+C on Windows
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
@ -149,10 +149,6 @@ sdl_configure(bool video_playback, bool disable_screensaver) {
}
#endif // _WIN32
if (!video_playback) {
return;
}
if (disable_screensaver) {
bool ok = SDL_DisableScreenSaver();
if (!ok) {
@ -544,7 +540,7 @@ scrcpy(struct scrcpy_options *options) {
}
}
sdl_configure(options->video_playback, options->disable_screensaver);
sdl_configure(options->disable_screensaver);
// Await for server without blocking Ctrl+C handling
bool connected;