diff --git a/client/src/config.c b/client/src/config.c index 552a3199..c9b38910 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -224,6 +224,13 @@ static struct Option options[] = .type = OPTION_TYPE_BOOL, .value.x_bool = false, }, + { + .module = "win", + .name = "autoScreensaver", + .description = "Prevent the screensaver from starting when guest requests it", + .type = OPTION_TYPE_BOOL, + .value.x_bool = false, + }, { .module = "win", .name = "alerts", @@ -473,21 +480,29 @@ bool config_load(int argc, char * argv[]) g_params.framePollInterval = option_get_int ("app", "framePollInterval" ); g_params.allowDMA = option_get_bool ("app", "allowDMA" ); - g_params.windowTitle = option_get_string("win", "title" ); - g_params.autoResize = option_get_bool ("win", "autoResize" ); - g_params.allowResize = option_get_bool ("win", "allowResize" ); - g_params.keepAspect = option_get_bool ("win", "keepAspect" ); - g_params.forceAspect = option_get_bool ("win", "forceAspect" ); - g_params.dontUpscale = option_get_bool ("win", "dontUpscale" ); - g_params.borderless = option_get_bool ("win", "borderless" ); - g_params.fullscreen = option_get_bool ("win", "fullScreen" ); - g_params.maximize = option_get_bool ("win", "maximize" ); - g_params.fpsMin = option_get_int ("win", "fpsMin" ); - g_params.showFPS = option_get_bool ("win", "showFPS" ); - g_params.ignoreQuit = option_get_bool ("win", "ignoreQuit" ); - g_params.noScreensaver = option_get_bool ("win", "noScreensaver"); - g_params.showAlerts = option_get_bool ("win", "alerts" ); - g_params.quickSplash = option_get_bool ("win", "quickSplash" ); + g_params.windowTitle = option_get_string("win", "title" ); + g_params.autoResize = option_get_bool ("win", "autoResize" ); + g_params.allowResize = option_get_bool ("win", "allowResize" ); + g_params.keepAspect = option_get_bool ("win", "keepAspect" ); + g_params.forceAspect = option_get_bool ("win", "forceAspect" ); + g_params.dontUpscale = option_get_bool ("win", "dontUpscale" ); + g_params.borderless = option_get_bool ("win", "borderless" ); + g_params.fullscreen = option_get_bool ("win", "fullScreen" ); + g_params.maximize = option_get_bool ("win", "maximize" ); + g_params.fpsMin = option_get_int ("win", "fpsMin" ); + g_params.showFPS = option_get_bool ("win", "showFPS" ); + g_params.ignoreQuit = option_get_bool ("win", "ignoreQuit" ); + g_params.noScreensaver = option_get_bool ("win", "noScreensaver" ); + g_params.autoScreensaver = option_get_bool ("win", "autoScreensaver"); + g_params.showAlerts = option_get_bool ("win", "alerts" ); + g_params.quickSplash = option_get_bool ("win", "quickSplash" ); + + if (g_params.noScreensaver && g_params.autoScreensaver) + { + fprintf(stderr, "win:noScreensaver (-S) and win:autoScreensaver " + "can't be used simultaneously\n"); + return false; + } switch(option_get_int("win", "rotate")) { diff --git a/client/src/main.c b/client/src/main.c index 6d9a2bb9..18cbd055 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -538,6 +538,15 @@ int main_frameThread(void * unused) break; } + if (g_params.autoScreensaver && g_state.autoIdleInhibitState != frame->blockScreensaver) + { + if (frame->blockScreensaver) + g_state.ds->inhibitIdle(); + else + g_state.ds->uninhibitIdle(); + g_state.autoIdleInhibitState = frame->blockScreensaver; + } + atomic_fetch_add_explicit(&g_state.frameCount, 1, memory_order_relaxed); lgSignalEvent(e_frame); lgmpClientMessageDone(queue); diff --git a/client/src/main.h b/client/src/main.h index faef8ff0..6ebf6769 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -92,6 +92,8 @@ struct AppState uint64_t resizeTimeout; bool resizeDone; + + bool autoIdleInhibitState; }; struct AppParams @@ -121,6 +123,7 @@ struct AppParams bool hideMouse; bool ignoreQuit; bool noScreensaver; + bool autoScreensaver; bool grabKeyboard; bool grabKeyboardOnFocus; int escapeKey;