summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakao Fujiwara <tfujiwar@redhat.com>2016-04-15 11:47:57 +0100
committerFrediano Ziglio <fziglio@redhat.com>2016-04-18 09:57:01 +0100
commitedda51d8911f13e8011e0fd44047d6857529f1ab (patch)
treee53ec9a95fa6c4c9e4598048f61eee6586ec1b4d
parentde5beccb0fe77fb5e1c75c7bb3bd6f4f06e66937 (diff)
Send Zenkaku_Hankaku key in JP keyboard
Zenkaku_Hankaku key has the different virtual-key codes between WM_KEYDOWN and WM_KEYUP and MapVirtualKey() cannot get the scancode from virtual-key code of WM_KEYDOWN (VK_DBE_DBCSCHAR) and spice-gtk didn't send the key press events and caused the desktop freeze with unlimited key release events. The fix is to get the scancode from virtual-key code of WM_KEYUP (VK_DBE_SBCSCHAR) and Zenkaku_Hankaku key works fine. Alt + Zenkaku_Hankaku key also has the different virtual-key code and MapVirtualKey() cannot get the scancode from the virtual-key and spice-gtk didn't send the key press events and Alt+Zenkaku_Hankaku could not be used. The fix is to get the scancode from virtual-key code of Zenkaku_Hankaku key (VK_DBE_SBCSCHAR). VK_CAPITAL, VK_DBE_ROMAN are also applied the similar fixes.
-rw-r--r--src/spice-widget.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 6f638fb..be0d747 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -30,6 +30,7 @@
#endif
#ifdef G_OS_WIN32
#include <windows.h>
+#include <ime.h>
#include <gdk/gdkwin32.h>
#ifndef MAPVK_VK_TO_VSC /* may be undefined in older mingw-headers */
#define MAPVK_VK_TO_VSC 0
@@ -1400,6 +1401,10 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
SpiceDisplay *display = SPICE_DISPLAY(widget);
SpiceDisplayPrivate *d = display->priv;
int scancode;
+#ifdef G_OS_WIN32
+ int native_scancode;
+ WORD langid = LOWORD(GetKeyboardLayout(0));
+#endif
#ifdef G_OS_WIN32
/* on windows, we ought to ignore the reserved key event? */
@@ -1446,9 +1451,42 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
scancode = vnc_display_keymap_gdk2xtkbd(d->keycode_map, d->keycode_maplen,
key->hardware_keycode);
#ifdef G_OS_WIN32
+ native_scancode = MapVirtualKey(key->hardware_keycode, MAPVK_VK_TO_VSC);
/* MapVirtualKey doesn't return scancode with needed higher byte */
- scancode = MapVirtualKey(key->hardware_keycode, MAPVK_VK_TO_VSC) |
- (scancode & 0xff00);
+ scancode = native_scancode | (scancode & 0xff00);
+
+ /* Some virtual-key codes are missed in MapVirtualKey(). */
+ switch (langid) {
+ case MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN):
+ if (native_scancode == 0) {
+ switch (key->hardware_keycode) {
+ case VK_DBE_DBCSCHAR: /* from Pressed Zenkaku_Hankaku */
+ case VK_KANJI: /* from Alt + Zenkaku_Hankaku */
+ case VK_DBE_ENTERIMECONFIGMODE:
+ /* from Ctrl+Alt+Zenkaku_Hankaku */
+ scancode = MapVirtualKey(VK_DBE_SBCSCHAR, MAPVK_VK_TO_VSC);
+ /* to Released Zenkaku_Hankaku */
+ break;
+ case VK_CAPITAL: /* from Shift + Eisu_toggle */
+ case VK_DBE_CODEINPUT: /* from Pressed Ctrl+Alt+Eisu_toggle */
+ case VK_DBE_NOCODEINPUT: /* from Released Ctrl+Alt+Eisu_toggle */
+ scancode = MapVirtualKey(VK_DBE_ALPHANUMERIC, MAPVK_VK_TO_VSC);
+ /* to Eisu_toggle */
+ break;
+ case VK_DBE_ROMAN: /* from Pressed Alt+Hiragana_Katakana */
+ case VK_KANA: /* from Ctrl+Shift+Hiragana_Katakana */
+ scancode = MapVirtualKey(VK_DBE_HIRAGANA, MAPVK_VK_TO_VSC);
+ /* to Hiragana_Katakana */
+ break;
+ case VK_DBE_ENTERWORDREGISTERMODE:
+ /* from Ctrl + Alt + Muhenkan */
+ scancode = MapVirtualKey(VK_NONCONVERT, MAPVK_VK_TO_VSC);
+ /* to Muhenkan */
+ break;
+ }
+ }
+ break;
+ }
#endif
switch (key->type) {