[Spice-devel] [spice-gtk 1/3] Send Zenkaku_Hankaku key in JP keyboard.
Fabiano FidĂȘncio
fabiano at fidencio.org
Mon Apr 4 08:01:47 UTC 2016
Ouch, sorry for resending this patch :-\
My intention was to submit another series completely not related to
this one, my bad :-\
On Mon, Apr 4, 2016 at 9:59 AM, Fabiano FidĂȘncio <fidencio at redhat.com> wrote:
> From: Takao Fujiwara <tfujiwar at redhat.com>
>
> MapVirtualKey() returns the scancode of the released Zenkaku_Hankaku key
> but does not pressed one and modifiered one. Any cases should be sent
> to use input method engines.
> ---
> src/spice-widget-priv.h | 1 +
> src/spice-widget.c | 37 +++++++++++++++++++++++++++++++++++--
> 2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
> index 95bca8a..05f6a90 100644
> --- a/src/spice-widget-priv.h
> +++ b/src/spice-widget-priv.h
> @@ -119,6 +119,7 @@ struct _SpiceDisplayPrivate {
> HHOOK keyboard_hook;
> int win_mouse[3];
> int win_mouse_speed;
> + HKL keyboard_layout;
> #endif
> guint keypress_delay;
> gint zoom_level;
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index f605439..4e026f3 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -644,6 +644,9 @@ static void spice_display_init(SpiceDisplay *display)
> d->grabseq = spice_grab_sequence_new_from_string("Control_L+Alt_L");
> d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);
> d->mouse_cursor = get_blank_cursor();
> +#ifdef G_OS_WIN32
> + d->keyboard_layout = GetKeyboardLayout(0);
> +#endif
> }
>
> static GObject *
> @@ -1418,6 +1421,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
> SpiceDisplay *display = SPICE_DISPLAY(widget);
> SpiceDisplayPrivate *d = display->priv;
> int scancode;
> + int native_scancode;
>
> #ifdef G_OS_WIN32
> /* on windows, we ought to ignore the reserved key event? */
> @@ -1464,9 +1468,38 @@ 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);
> +
> + /* Some OEM virtual-key codes are missed in MapVirtualKey(). */
> + switch (HIWORD(d->keyboard_layout)) {
> + case 0x411: /* JP keyboard */
> + if (native_scancode == 0) {
> + switch (key->hardware_keycode) {
> + case VK_OEM_ENLW: /* from Pressed Zenkaku_Hankaku */
> + case VK_KANJI: /* from Alt + Zenkaku_Hankaku */
> + scancode = MapVirtualKey(VK_OEM_AUTO, MAPVK_VK_TO_VSC);
> + /* to Released Zenkaku_Hankaku */
> + goto got_scancode;
> + case VK_CAPITAL: /* from Alt + Eisu_toggle */
> + scancode = MapVirtualKey(VK_OEM_ATTN, MAPVK_VK_TO_VSC);
> + /* to Eisu_toggle */
> + goto got_scancode;
> + case VK_OEM_BACKTAB: /* from Alt + Hiragana_Katakana */
> + scancode = MapVirtualKey(VK_OEM_COPY, MAPVK_VK_TO_VSC);
> + /* to Hiragana_Katakana */
> + goto got_scancode;
> + default:;
> + }
> + }
> + break;
> + default:;
> + }
> +
> /* 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);
> +
> +got_scancode:
> +
> #endif
>
> switch (key->type) {
> --
> 2.7.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
--
Fabiano FidĂȘncio
More information about the Spice-devel
mailing list