[Spice-devel] [spice-gtk 2/3] Send key release event for some keys in JP keyboard.
Frediano Ziglio
fziglio at redhat.com
Thu Mar 31 13:19:58 UTC 2016
>
> From: Takao Fujiwara <tfujiwar at redhat.com>
>
> Some of the keys in JP keyboard do no send WM_KEYUP and it causes
> unlimited key events on Linux desktop. This sends the virtual
> key release events to avoid the desktop hangup.
> ---
> src/spice-widget.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 4e026f3..5e71d1b 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -1422,6 +1422,7 @@ static gboolean key_event(GtkWidget *widget,
> GdkEventKey *key)
> SpiceDisplayPrivate *d = display->priv;
> int scancode;
> int native_scancode;
> + gboolean no_key_release = FALSE;
>
> #ifdef G_OS_WIN32
> /* on windows, we ought to ignore the reserved key event? */
> @@ -1500,11 +1501,28 @@ static gboolean key_event(GtkWidget *widget,
> GdkEventKey *key)
>
> got_scancode:
>
> + /* Some keys do not send WM_KEYUP */
> + switch (HIWORD(d->keyboard_layout)) {
LOWORD
> + case 0x411: /* JP keyboard */
See comment about MAKELANGID on previous patch
> + switch (key->hardware_keycode) {
> + case VK_KANJI: /* Alt + Zenkaku_Hankaku */
> + case VK_OEM_ATTN: /* Eisu_toggle */
> + case VK_OEM_COPY: /* Hiragana_Katakana */
> + case VK_OEM_BACKTAB: /* Alt + Hiragana_Katakana */
> + no_key_release = TRUE;
> + break;
Unfortunately this is not exactly true. Some keys are just inverted,
some others depends on IME mode.
Sending always the release cause in some case to send 2 times the press/release
combination. This could cause some issues depending on guest settings.
Usually however this code produce multiple releases which are harmless.
> + default:;
> + }
> + break;
> + default:;
> + }
> #endif
>
> switch (key->type) {
> case GDK_KEY_PRESS:
> send_key(display, scancode, SEND_KEY_PRESS, !key->is_modifier);
> + if (no_key_release)
> + send_key(display, scancode, SEND_KEY_RELEASE,
> !key->is_modifier);
> break;
> case GDK_KEY_RELEASE:
> send_key(display, scancode, SEND_KEY_RELEASE, !key->is_modifier);
Frediano
More information about the Spice-devel
mailing list