[Spice-devel] [spice-gtk 1/3] Send Zenkaku_Hankaku key in JP keyboard

Takao Fujiwara tfujiwar at redhat.com
Tue Apr 12 11:12:07 UTC 2016


On 04/12/16 00:52, Frediano Ziglio-san wrote:
>>
>> 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.
>> ---
>>   src/spice-widget-priv.h |  1 +
>>   src/spice-widget.c      | 78
>>   +++++++++++++++++++++++++++++++++++++++++++++++--
>>   2 files changed, 77 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
>> index 95bca8a..95a8371 100644
>> --- a/src/spice-widget-priv.h
>> +++ b/src/spice-widget-priv.h
>> @@ -117,6 +117,7 @@ struct _SpiceDisplayPrivate {
>>       gint                    mark;
>>   #ifdef WIN32
>>       HHOOK                   keyboard_hook;
>> +    HHOOK                   call_wnd_proc_hook;
>>       int                     win_mouse[3];
>>       int                     win_mouse_speed;
>>   #endif
>> diff --git a/src/spice-widget.c b/src/spice-widget.c
>> index f605439..49e1f2a 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
>> @@ -99,6 +100,7 @@ static guint signals[SPICE_DISPLAY_LAST_SIGNAL];
>>
>>   #ifdef G_OS_WIN32
>>   static HWND win32_window = NULL;
>> +static HKL  win32_keymap;
>>   #endif
>>
>>   static void update_keyboard_grab(SpiceDisplay *display);
>> @@ -644,6 +646,10 @@ 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
>> +    win32_keymap = GetKeyboardLayout(0);
>> +#endif
>>   }
>>
>>   static GObject *
>> @@ -757,6 +763,20 @@ static LRESULT CALLBACK keyboard_hook_cb(int code,
>> WPARAM wparam, LPARAM lparam)
>>       }
>>       return CallNextHookEx(NULL, code, wparam, lparam);
>>   }
>> +
>> +static LRESULT CALLBACK call_wnd_proc_hook_cb(int code, WPARAM wparam,
>> LPARAM lparam)
>> +{
>> +    if  (code >= 0) {
>> +        CWPSTRUCT *cwp = (CWPSTRUCT *) lparam;
>> +        switch (cwp->message) {
>> +        case WM_INPUTLANGCHANGE:
>> +            win32_keymap = (HKL) cwp->lParam;
>> +            break;
>> +        default:;
>> +        }
>> +    }
>> +    return CallNextHookEx(NULL, code, wparam, lparam);
>> +}
>>   #endif
>>
>
> I think instead of using an hook would be better to use gdk_window_add_filter.
> You are registering the hook only when we have the grab so you won't
> get the message if we don't have the focus.
> Even better ...

I updated the patch.

Fujiwara


More information about the Spice-devel mailing list