[Spice-devel] [spice-gtk 2/3] Send key release event for some keys in JP keyboard
Takao Fujiwara
tfujiwar at redhat.com
Wed Apr 6 04:31:59 UTC 2016
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.
---
src/spice-widget.c | 49
+++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 49e1f2a..5242288 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1452,6 +1452,7 @@ static gboolean key_event(GtkWidget *widget,
GdkEventKey *key)
int scancode;
#ifdef G_OS_WIN32
int native_scancode;
+ gboolean no_key_release = FALSE;
#endif
#ifdef G_OS_WIN32
@@ -1541,11 +1542,59 @@ static gboolean key_event(GtkWidget *widget,
GdkEventKey *key)
got_scancode:
+ /* 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 (LOWORD(win32_keymap)) {
+ 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;
+ default:;
+ }
+ break;
+ default:;
+ }
#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);
--
2.5.0
More information about the Spice-devel
mailing list