From bd42445ea751dafe8b6ce7a49fd2169a29b07b10 Mon Sep 17 00:00:00 2001 From: Samuel Bowman Date: Wed, 20 May 2020 21:13:42 -0400 Subject: [PATCH] [client] add option to capture input on start --- client/src/config.c | 8 ++++++++ client/src/main.c | 8 ++++++++ client/src/main.h | 1 + 3 files changed, 17 insertions(+) diff --git a/client/src/config.c b/client/src/config.c index 7e2c8f9c..f45fe45c 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -309,6 +309,13 @@ static struct Option options[] = .type = OPTION_TYPE_BOOL, .value.x_bool = true }, + { + .module = "spice", + .name = "captureOnStart", + .description = "Capture mouse and keyboard on start", + .type = OPTION_TYPE_BOOL, + .value.x_bool = false + }, {0} }; @@ -413,6 +420,7 @@ bool config_load(int argc, char * argv[]) } params.scaleMouseInput = option_get_bool("spice", "scaleCursor"); + params.captureOnStart = option_get_bool("spice", "captureOnStart"); } return true; diff --git a/client/src/main.c b/client/src/main.c index 8fa1ed9d..5b2f3447 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1394,6 +1394,14 @@ static int lg_run() SDL_ShowCursor(SDL_DISABLE); } + if (params.captureOnStart) + { + state.serverMode = true; + spice_mouse_mode(state.serverMode); + SDL_SetWindowGrab(state.window, state.serverMode); + DEBUG_INFO("Server Mode: %s", state.serverMode ? "on" : "off"); + } + // setup the startup condition if (!(e_startup = lgCreateEvent(false, 0))) { diff --git a/client/src/main.h b/client/src/main.h index f4d23256..d586187c 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -124,6 +124,7 @@ struct AppParams bool grabKeyboard; SDL_Scancode escapeKey; bool showAlerts; + bool captureOnStart; unsigned int cursorPollInterval; unsigned int framePollInterval;