GUACAMOLE-518: Ensure all keys are released even if the key pressed client-side is unknown except through dead keys.

This commit is contained in:
Michael Jumper 2020-06-24 00:50:23 -07:00
parent 3798d85bd1
commit 628f2fd815

View File

@ -651,33 +651,20 @@ int guac_rdp_keyboard_update_keysym(guac_rdp_keyboard* keyboard,
* are tracked server-side, as well (to ensure that the key count remains
* correct, even if a user sends extra unbalanced or excessive press and
* release events) */
if (key != NULL && source == GUAC_RDP_KEY_SOURCE_CLIENT) {
if (source == GUAC_RDP_KEY_SOURCE_CLIENT && key != NULL) {
if (pressed && !key->user_pressed) {
keyboard->user_pressed_keys++;
key->user_pressed = 1;
}
else if (!pressed && key->user_pressed) {
keyboard->user_pressed_keys--;
key->user_pressed = 0;
/* Reset RDP server keyboard state (releasing any automatically
* pressed keys) once all keys have been released on the client
* side */
if (keyboard->user_pressed_keys == 0)
guac_rdp_keyboard_reset(keyboard);
}
}
}
/* If key is known, ignore the key event entirely if state is not actually
* changing */
if (key != NULL) {
if ((!pressed && key->pressed == NULL) || (pressed && key->pressed != NULL))
return 0;
}
/* Send events and update server-side lock state only if server-side key
* state is changing (or if server-side state of this key is untracked) */
if (key == NULL || (pressed && key->pressed == NULL) || (!pressed && key->pressed != NULL)) {
/* Toggle locks on keydown */
if (pressed)
@ -698,6 +685,14 @@ int guac_rdp_keyboard_update_keysym(guac_rdp_keyboard* keyboard,
guac_rdp_keyboard_send_missing_key(keyboard, keysym);
}
}
/* Reset RDP server keyboard state (releasing any automatically
* pressed keys) once all keys have been released on the client
* side */
if (source == GUAC_RDP_KEY_SOURCE_CLIENT && keyboard->user_pressed_keys == 0)
guac_rdp_keyboard_reset(keyboard);
return 0;
}