[client] spice: add option to ignore the windows key

If active this will prevent the client from sending keyboard events for
the windows key. The idea is to allow people to keep the windows key
bound to their WMs default action without causing the Windows start menu
to open
This commit is contained in:
Geoffrey McRae 2021-01-04 18:22:39 +11:00
parent 33b117e732
commit 8fd08cdd79
3 changed files with 22 additions and 1 deletions

View File

@ -260,6 +260,13 @@ static struct Option options[] =
.value.x_int = SDL_SCANCODE_SCROLLLOCK,
.toString = optScancodeToString
},
{
.module = "input",
.name = "ignoreWindowsKeys",
.description = "Do not pass events for the windows keys to the guest",
.type = OPTION_TYPE_BOOL,
.value.x_bool = false
},
{
.module = "input",
.name = "hideCursor",
@ -443,6 +450,7 @@ bool config_load(int argc, char * argv[])
params.grabKeyboard = option_get_bool ("input", "grabKeyboard" );
params.grabKeyboardOnFocus = option_get_bool ("input", "grabKeyboardOnFocus");
params.escapeKey = option_get_int ("input", "escapeKey" );
params.ignoreWindowsKeys = option_get_bool ("input", "ignoreWindowsKeys" );
params.hideMouse = option_get_bool ("input", "hideCursor" );
params.mouseSens = option_get_int ("input", "mouseSens" );
params.mouseRedraw = option_get_bool ("input", "mouseRedraw" );

View File

@ -1213,7 +1213,7 @@ int eventFilter(void * userdata, SDL_Event * event)
case SDL_KEYDOWN:
{
SDL_Scancode sc = event->key.keysym.scancode;
if (sc == params.escapeKey)
if (sc == params.escapeKey && !g_state.escapeActive)
{
g_state.escapeActive = true;
g_state.escapeAction = -1;
@ -1229,6 +1229,11 @@ int eventFilter(void * userdata, SDL_Event * event)
if (g_state.ignoreInput || !params.useSpiceInput)
break;
if (params.ignoreWindowsKeys &&
(sc == SDL_SCANCODE_LGUI || sc == SDL_SCANCODE_RGUI))
break;
uint32_t scancode = mapScancode(sc);
if (scancode == 0)
break;
@ -1299,7 +1304,10 @@ int eventFilter(void * userdata, SDL_Event * event)
{
KeybindHandle handle = g_state.bindings[sc];
if (handle)
{
handle->callback(sc, handle->opaque);
break;
}
}
if (sc == params.escapeKey)
@ -1313,6 +1321,10 @@ int eventFilter(void * userdata, SDL_Event * event)
if (!g_state.keyDown[sc])
break;
if (params.ignoreWindowsKeys &&
(sc == SDL_SCANCODE_LGUI || sc == SDL_SCANCODE_RGUI))
break;
uint32_t scancode = mapScancode(sc);
if (scancode == 0)
break;

View File

@ -121,6 +121,7 @@ struct AppParams
bool grabKeyboard;
bool grabKeyboardOnFocus;
SDL_Scancode escapeKey;
bool ignoreWindowsKeys;
bool showAlerts;
bool captureOnStart;
bool quickSplash;