2021-08-09 04:27:50 +00:00
|
|
|
From 943d37444d9cc0881cb5fff87bdd4b9efd5abdb4 Mon Sep 17 00:00:00 2001
|
|
|
|
From: fujiwarat <takao.fujiwara1@gmail.com>
|
|
|
|
Date: Mon, 9 Aug 2021 12:49:15 +0900
|
|
|
|
Subject: [PATCH] client/gtk2/ibusimcontext: Fix a key event loop with
|
|
|
|
forwarding keys.
|
|
|
|
|
|
|
|
_ibus_context_forward_key_event_cb() caused a key event loop in
|
|
|
|
_key_snooper_cb() with key release events.
|
|
|
|
---
|
|
|
|
client/gtk2/ibusimcontext.c | 11 +++++++++--
|
|
|
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
|
|
|
|
index da9a402f..e66125df 100644
|
|
|
|
--- a/client/gtk2/ibusimcontext.c
|
|
|
|
+++ b/client/gtk2/ibusimcontext.c
|
|
|
|
@@ -366,6 +366,10 @@ ibus_im_context_commit_event (IBusIMContext *ibusimcontext,
|
|
|
|
g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text);
|
|
|
|
g_object_unref (text);
|
|
|
|
_request_surrounding_text (ibusimcontext);
|
|
|
|
+#if !GTK_CHECK_VERSION (3, 98, 4)
|
|
|
|
+ /* Avoid a loop with _ibus_context_forward_key_event_cb() */
|
|
|
|
+ event->state |= IBUS_HANDLED_MASK;
|
|
|
|
+#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
@@ -643,12 +647,15 @@ _key_snooper_cb (GtkWidget *widget,
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
- if (ibusimcontext != NULL) {
|
|
|
|
+ if (ibusimcontext != NULL && event->type == GDK_KEY_PRESS) {
|
|
|
|
/* "retrieve-surrounding" signal sometimes calls unref by
|
|
|
|
* gtk_im_multicontext_get_slave() because priv->context_id is not
|
|
|
|
* the latest than global_context_id in GtkIMMulticontext.
|
|
|
|
* Since _focus_im_context is gotten by the focus_in event,
|
|
|
|
* it would be good to call ref here.
|
|
|
|
+ *
|
|
|
|
+ * Most release key events would be redundant from
|
|
|
|
+ * _ibus_context_forward_key_event_cb ().
|
|
|
|
*/
|
|
|
|
g_object_ref (ibusimcontext);
|
|
|
|
_request_surrounding_text (ibusimcontext);
|
|
|
|
@@ -657,7 +664,7 @@ _key_snooper_cb (GtkWidget *widget,
|
|
|
|
|
|
|
|
retval = _process_key_event (ibuscontext, event, ibusimcontext);
|
|
|
|
|
|
|
|
- if (ibusimcontext != NULL) {
|
|
|
|
+ if (ibusimcontext != NULL && event->type == GDK_KEY_PRESS) {
|
|
|
|
/* unref ibusimcontext could call ibus_im_context_finalize here
|
|
|
|
* because "retrieve-surrounding" signal could call unref.
|
|
|
|
*/
|
|
|
|
--
|
|
|
|
2.28.0
|
|
|
|
|