From 5cfe838715097d61b50da55f80bcff2c698ca885 Mon Sep 17 00:00:00 2001 From: Changwoo Ryu Date: Fri, 18 Feb 2022 09:07:02 +0900 Subject: [PATCH] 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 --- client/gtk2/ibusimcontext.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index c2df3a87..a5e5e792 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -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); }