Skip to content

Commit

Permalink
Allow enabling screensaver when running under SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
Aciz committed Nov 6, 2023
1 parent 5f183a6 commit 991459c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ cvar_t *r_swapInterval;
cvar_t *r_glDriver;
#else
cvar_t *r_sdlDriver;
cvar_t *r_sdlAllowScreenSaver;
#endif
cvar_t *r_displayRefresh;
cvar_t *r_fullscreen;
Expand Down Expand Up @@ -4309,6 +4310,8 @@ static void CL_InitGLimp_Cvars( void )
#else
r_sdlDriver = Cvar_Get( "r_sdlDriver", "", CVAR_ARCHIVE_ND | CVAR_LATCH | CVAR_UNSAFE );
Cvar_SetDescription( r_sdlDriver, "Override hint to SDL which video driver to use, example \"x11\" or \"wayland\"" );
r_sdlAllowScreenSaver = Cvar_Get( "r_sdlAllowScreenSaver", "0", CVAR_ARCHIVE_ND | CVAR_LATCH | CVAR_UNSAFE );
Cvar_SetDescription( r_sdlAllowScreenSaver, "Allow screen to sleep while the game is running, requires full restart");
#endif

r_displayRefresh = Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH | CVAR_UNSAFE );
Expand Down
1 change: 1 addition & 0 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ extern cvar_t *r_swapInterval;
extern cvar_t *r_glDriver;
#else
extern cvar_t *r_sdlDriver;
extern cvar_t *r_sdlAllowScreenSaver;
#endif
extern cvar_t *r_displayRefresh;
extern cvar_t *r_fullscreen;
Expand Down
5 changes: 5 additions & 0 deletions src/sdl/sdl_glimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ static rserr_t GLimp_StartDriverAndSetMode( int mode, const char *modeFS, qboole
fullscreen = qfalse;
}

if ( r_sdlAllowScreenSaver->integer )
{
SDL_SetHint( SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1" );
}

if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
{
const char *driverName;
Expand Down

0 comments on commit 991459c

Please sign in to comment.