Blob Blame History Raw
From ef3aaa7bee7dd4c9ab3ccbe5a62d20be3b06a309 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 18 Apr 2013 09:48:25 +0900
Subject: [PATCH] IBusIMContext needs to reconnect IBusBus when IBusBus is
 disconnected.

---
 client/gtk2/ibusimcontext.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 49598b4..8c7dbcc 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -1474,6 +1474,25 @@ _ibus_context_destroy_cb (IBusInputContext *ibuscontext,
 
     g_signal_emit (ibusimcontext, _signal_preedit_changed_id, 0);
     g_signal_emit (ibusimcontext, _signal_preedit_end_id, 0);
+
+    /* This destroy callback can be called when the client app connects to
+     * IBusBus and the app is disconnected. E.g. gnome-shell connects to
+     * IBusBus and it has StEntry input text and ibus can be restarted.
+     * And each ibusimcontext also needs to reconnect IBusBus here. */
+    if (!ibus_bus_is_connected (_bus)) {
+        g_signal_handlers_disconnect_by_func (_bus,
+                                              G_CALLBACK (_bus_connected_cb),
+                                              ibusimcontext);
+        g_object_unref (_bus);
+        _bus = ibus_bus_new_async ();
+
+        if (ibus_bus_is_connected (_bus)) {
+            _create_input_context (ibusimcontext);
+        }
+
+        g_signal_connect (_bus, "connected", G_CALLBACK (_bus_connected_cb),
+                          ibusimcontext);
+    }
 }
 
 static void
-- 
1.8.0