diff options
author | Takao Fujiwara <tfujiwar@redhat.com> | 2016-04-15 18:08:37 +0900 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2016-04-18 09:57:01 +0100 |
commit | 046de27c2eea2b3ee2ade80780f51b2ca140f92d (patch) | |
tree | 2fb7f167af4de1f5ae7dd936f137a02d290f525a | |
parent | edda51d8911f13e8011e0fd44047d6857529f1ab (diff) |
Send key release event for some keys in JP keyboard
With the previous fix, WM_KEYDOWN of Alt+Zenkaku_Hankaku (VK_KANJI) can
be sent with spice-gtk but Alt+Zenkaku_Hankaku does not send the WM_KEYUP
event in Windows and it caused Linux desktop freeze with unlimited key
press events.
The proposed fix is to send the key release event in spice-gtk.
VK_DBE_ALPHANUMERIC, VK_DBE_HIRAGANA, VK_DBE_ROMAN are applied the
similar fixes.
-rw-r--r-- | src/spice-widget.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/spice-widget.c b/src/spice-widget.c index be0d747..4878e00 100644 --- a/src/spice-widget.c +++ b/src/spice-widget.c @@ -1404,6 +1404,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key) #ifdef G_OS_WIN32 int native_scancode; WORD langid = LOWORD(GetKeyboardLayout(0)); + gboolean no_key_release = FALSE; #endif #ifdef G_OS_WIN32 @@ -1487,11 +1488,58 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key) } break; } + + /* Emulate KeyRelease events for the following keys. + * + * Alt+Zenkaku_Hankaku generates WM_KEYDOWN VK_KANJI and no WM_KEYUP + * and it caused unlimited VK_KANJI in Linux desktop and the desktop + * hung up. We send WM_KEYUP VK_KANJI here to avoid unlimited events. + * + * Eisu_toggle generates WM_KEYDOWN VK_DBE_ALPHANUMERIC only in + * English mode, WM_KEYDOWN VK_DBE_ALPHANUMERIC and WM_KEYUP + * VK_DBE_HIRAGANA in Japanese mode, and it caused unlimited + * VK_DBE_ALPHANUMERIC in Linux desktop. + * Since VK_DBE_HIRAGANA is also assigned in Hiragana key, + * we send WM_KEYUP VK_DBE_ALPHANUMERIC here to avoid unlimited events. + * No KeyPress VK_DBE_HIRAGANA seems harmless. + * + * Hiragana_Katakana generates WM_KEYDOWN VK_DBE_HIRAGANA and + * WM_KEYUP VK_DBE_ALPHANUMERIC in English mode, WM_KEYDOWN + * VK_DBE_HIRAGANA only in Japanese mode, and it caused unlimited + * VK_DBE_HIRAGANA in Linux desktop. + * + * Alt+Hiragana_Katakana generates WM_KEYUP VK_DBE_NOROMAN and + * WM_KEYDOWN VK_DBE_ROMAN but the KeyRelease is called before + * KeyDown is called and it caused unlimited VK_DBE_ROMAN. + * We ignore the scancode of VK_DBE_NOROMAN and emulate WM_KEYUP + * VK_DBE_ROMAN. + * + * Ctrl+Alt+Zenkaku_Hankaku generates WM_KEYDOWN VK_DBE_ENTERIMECONFIGMODE + * and no WM_KEYUP and it caused unlimited VK_DBE_ENTERIMECONFIGMODE + * in Linux desktop. + */ + switch (langid) { + case MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN): + switch (key->hardware_keycode) { + case VK_KANJI: /* Alt + Zenkaku_Hankaku */ + case VK_DBE_ALPHANUMERIC: /* Eisu_toggle */ + case VK_DBE_HIRAGANA: /* Hiragana_Katakana */ + case VK_DBE_ROMAN: /* Alt+Hiragana_Katakana */ + case VK_DBE_ENTERIMECONFIGMODE: /* Ctrl + Alt + Zenkaku_Hankaku */ + no_key_release = TRUE; + break; + } + break; + } #endif switch (key->type) { case GDK_KEY_PRESS: send_key(display, scancode, SEND_KEY_PRESS, !key->is_modifier); +#ifdef G_OS_WIN32 + if (no_key_release) + send_key(display, scancode, SEND_KEY_RELEASE, !key->is_modifier); +#endif break; case GDK_KEY_RELEASE: send_key(display, scancode, SEND_KEY_RELEASE, !key->is_modifier); |