[client] allow the system screensaver to operate, -S to disable

This commit is contained in:
Geoffrey McRae 2018-05-29 08:34:52 +10:00
parent 64ad862116
commit afdae8efc0

View File

@ -99,6 +99,7 @@ struct AppParams
bool scaleMouseInput; bool scaleMouseInput;
bool hideMouse; bool hideMouse;
bool ignoreQuit; bool ignoreQuit;
bool allowScreensaver;
bool forceRenderer; bool forceRenderer;
unsigned int forceRendererIndex; unsigned int forceRendererIndex;
@ -129,6 +130,7 @@ struct AppParams params =
.scaleMouseInput = true, .scaleMouseInput = true,
.hideMouse = true, .hideMouse = true,
.ignoreQuit = false, .ignoreQuit = false,
.allowScreensaver = true,
.forceRenderer = false .forceRenderer = false
}; };
@ -802,6 +804,9 @@ int run()
if (params.fullscreen) if (params.fullscreen)
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (params.allowScreensaver)
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
// set the compositor hint to bypass for low latency // set the compositor hint to bypass for low latency
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
@ -1051,6 +1056,7 @@ void doHelp(char * app)
" -w WIDTH Initial window width [current: %u]\n" " -w WIDTH Initial window width [current: %u]\n"
" -b HEIGHT Initial window height [current: %u]\n" " -b HEIGHT Initial window height [current: %u]\n"
" -Q Ignore requests to quit (ie: Alt+F4)\n" " -Q Ignore requests to quit (ie: Alt+F4)\n"
" -S Disable the screensaver\n"
"\n" "\n"
" -l License information\n" " -l License information\n"
"\n", "\n",
@ -1150,6 +1156,7 @@ static bool load_config(const char * configFile)
if (config_setting_lookup_bool(global, "borderless" , &itmp)) params.borderless = (itmp != 0); if (config_setting_lookup_bool(global, "borderless" , &itmp)) params.borderless = (itmp != 0);
if (config_setting_lookup_bool(global, "fullScreen" , &itmp)) params.fullscreen = (itmp != 0); if (config_setting_lookup_bool(global, "fullScreen" , &itmp)) params.fullscreen = (itmp != 0);
if (config_setting_lookup_bool(global, "ignoreQuit" , &itmp)) params.ignoreQuit = (itmp != 0); if (config_setting_lookup_bool(global, "ignoreQuit" , &itmp)) params.ignoreQuit = (itmp != 0);
if (config_setting_lookup_bool(global, "allowScreensaver", &itmp)) params.allowScreensaver = (itmp != 0);
if (config_setting_lookup_int(global, "x", &params.x)) params.center = false; if (config_setting_lookup_int(global, "x", &params.x)) params.center = false;
if (config_setting_lookup_int(global, "y", &params.y)) params.center = false; if (config_setting_lookup_int(global, "y", &params.y)) params.center = false;
@ -1279,7 +1286,7 @@ int main(int argc, char * argv[])
for(;;) for(;;)
{ {
switch(getopt(argc, argv, "hC:f:L:sc:p:jMvK:kg:o:anrdFx:y:w:b:Ql")) switch(getopt(argc, argv, "hC:f:L:sc:p:jMvK:kg:o:anrdFx:y:w:b:QSl"))
{ {
case '?': case '?':
case 'h': case 'h':
@ -1500,6 +1507,10 @@ int main(int argc, char * argv[])
params.ignoreQuit = true; params.ignoreQuit = true;
continue; continue;
case 'S':
params.allowScreensaver = false;
continue;
case 'l': case 'l':
doLicense(); doLicense();
return 0; return 0;