From e6601f205c0e6472bb75eae3c2dfaf8d4dcfab89 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Tue, 23 Aug 2022 18:16:46 +0200 Subject: [PATCH] feat(linux): match state of original event when creating fake event We forward a fake event for both keydown and keyup. This change will set the flag on the fake event so that we get keydown and keyup. This is probably not technically necessary, but it helps in debugging because you can then see that both fake events still belong to the same keypress. --- linux/ibus-keyman/src/engine.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linux/ibus-keyman/src/engine.c b/linux/ibus-keyman/src/engine.c index abc349aae1..3df284f1c4 100644 --- a/linux/ibus-keyman/src/engine.c +++ b/linux/ibus-keyman/src/engine.c @@ -698,6 +698,7 @@ static gboolean process_end_action(IBusKeymanEngine *keyman) { g_assert(keyman != NULL); if (((IBusEngine *)keyman)->client_capabilities & IBUS_CAP_PREFILTER) { + guint state = keyman->commit_item->state; keyman->commit_item++; if (keyman->commit_item > &keyman->commit_queue[MAX_QUEUE_SIZE-1]) { g_error("Overflow of keyman commit_queue!"); @@ -709,7 +710,12 @@ process_end_action(IBusKeymanEngine *keyman) { // generated will be processed before the character we're adding. We need to send a // valid keyval/keycode combination so that it doesn't get swallowed by GTK but which // isn't very likely used in real keyboards. F24 seems to work for that. - ibus_engine_forward_key_event((IBusEngine*)keyman, KEYMAN_NOCHAR_KEYSYM, KEYMAN_F24_KEYCODE_OUTPUT_SENTINEL, IBUS_PREFILTER_MASK); + ibus_engine_forward_key_event((IBusEngine*)keyman, + KEYMAN_NOCHAR_KEYSYM, + KEYMAN_F24_KEYCODE_OUTPUT_SENTINEL, + (state & IBUS_RELEASE_MASK) + ? IBUS_PREFILTER_MASK | IBUS_RELEASE_MASK + : IBUS_PREFILTER_MASK); } else { if (keyman->commit_item->char_buffer != NULL) { ibus_keyman_engine_commit_string(keyman, keyman->commit_item->char_buffer);