[Spice-commits] 3 commits - src/spice-widget.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Mon Apr 18 08:58:10 UTC 2016
src/spice-widget.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 97 insertions(+), 2 deletions(-)
New commits:
commit 2293b293e83a95a9b939a04a916adf8abed1a100
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date: Fri Apr 15 18:09:37 2016 +0900
Send Hangul key in KR keyboard
Korean keyboard assigns Hangul key on the position of Right Alt and
Left Alt and Hangul keys have the different scancodes but MapVirtualKey()
returned the same scancode and could not use Hangul key on Linux desktop.
The fix is to send the right scancode of VK_HANGUL.
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 4878e00..617cd26 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -30,6 +30,7 @@
#endif
#ifdef G_OS_WIN32
#include <windows.h>
+#include <dinput.h>
#include <ime.h>
#include <gdk/gdkwin32.h>
#ifndef MAPVK_VK_TO_VSC /* may be undefined in older mingw-headers */
@@ -1487,6 +1488,14 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
}
}
break;
+ case MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN):
+ if (key->hardware_keycode == VK_HANGUL && native_scancode == DIK_LALT) {
+ /* Left Alt (VK_MENU) has the scancode DIK_LALT (0x38) but
+ * Hangul (VK_HANGUL) has the scancode 0x138
+ */
+ scancode = native_scancode | 0x100;
+ }
+ break;
}
/* Emulate KeyRelease events for the following keys.
commit 046de27c2eea2b3ee2ade80780f51b2ca140f92d
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date: Fri Apr 15 18:08:37 2016 +0900
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.
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);
commit edda51d8911f13e8011e0fd44047d6857529f1ab
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date: Fri Apr 15 11:47:57 2016 +0100
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.
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) {
More information about the Spice-commits
mailing list