client/gtk2/ibusimcontext: Fix forward key keycode for GTK4

When a keycode is provided (!= 0) for a forwarded key event, convert it to a
GTK keycode before passing it to gtk_im_context_filter_key().

Also free GdkKeymapKey after gdk_display_map_keyval() is called.

BUG=https://github.com/ibus/ibus/issues/2380
BUG=https://github.com/ibus/ibus/issues/2382
This commit is contained in:
Changwoo Ryu 2022-02-18 09:07:02 +09:00 коммит произвёл fujiwarat
Родитель b5423f0cff
Коммит 5cfe838715
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -1945,7 +1945,9 @@ _ibus_context_forward_key_event_cb (IBusInputContext *ibuscontext,
#if GTK_CHECK_VERSION (3, 98, 4)
int group = 0;
g_return_if_fail (GTK_IS_IM_CONTEXT (ibusimcontext));
if (keycode == 0 && ibusimcontext->client_window) {
if (keycode != 0) {
keycode += 8; // to GTK keycode
} else if (ibusimcontext->client_window) {
GdkDisplay *display =
gtk_widget_get_display (ibusimcontext->client_window);
GdkKeymapKey *keys = NULL;
@ -1953,6 +1955,7 @@ _ibus_context_forward_key_event_cb (IBusInputContext *ibuscontext,
if (gdk_display_map_keyval (display, keyval, &keys, &n_keys)) {
keycode = keys->keycode;
group = keys->group;
g_free (keys);
} else {
g_warning ("Failed to parse keycode from keyval %x", keyval);
}