[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, .value.x_int = SDL_SCANCODE_SCROLLLOCK,
.toString = optScancodeToString .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", .module = "input",
.name = "hideCursor", .name = "hideCursor",
@ -443,6 +450,7 @@ bool config_load(int argc, char * argv[])
params.grabKeyboard = option_get_bool ("input", "grabKeyboard" ); params.grabKeyboard = option_get_bool ("input", "grabKeyboard" );
params.grabKeyboardOnFocus = option_get_bool ("input", "grabKeyboardOnFocus"); params.grabKeyboardOnFocus = option_get_bool ("input", "grabKeyboardOnFocus");
params.escapeKey = option_get_int ("input", "escapeKey" ); params.escapeKey = option_get_int ("input", "escapeKey" );
params.ignoreWindowsKeys = option_get_bool ("input", "ignoreWindowsKeys" );
params.hideMouse = option_get_bool ("input", "hideCursor" ); params.hideMouse = option_get_bool ("input", "hideCursor" );
params.mouseSens = option_get_int ("input", "mouseSens" ); params.mouseSens = option_get_int ("input", "mouseSens" );
params.mouseRedraw = option_get_bool ("input", "mouseRedraw" ); params.mouseRedraw = option_get_bool ("input", "mouseRedraw" );

View File

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

View File

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