Skip to content

Commit

Permalink
client/gtk2/ibusimcontext: Fix forward key keycode for GTK4
Browse files Browse the repository at this point in the history
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=#2380
BUG=#2382
  • Loading branch information
changwoo authored and fujiwarat committed Feb 18, 2022
1 parent b5423f0 commit 5cfe838
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/gtk2/ibusimcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1945,14 +1945,17 @@ _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;
gint n_keys = 0;
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);
}
Expand Down

0 comments on commit 5cfe838

Please sign in to comment.