[client] wm: optionally disable screensaver when requested in guest

This commit adds a new option, win:autoScreensaver, which when set to yes,
automatically disables the screensaver when requested by an application
running in the guest, and enables it when the application no longer wants
it disabled.

This is useful when doing media playback in the guest.
This commit is contained in:
Quantum 2021-02-03 18:01:53 -05:00 committed by Geoffrey McRae
parent 8e98f863b6
commit 0c9ecdfcb5
3 changed files with 42 additions and 15 deletions

View File

@ -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",
@ -485,10 +492,18 @@ bool config_load(int argc, char * argv[])
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.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"))
{
case 0 : g_params.winRotate = LG_ROTATE_0 ; break;

View File

@ -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);

View File

@ -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;