summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Huang <shawn.p.huang@gmail.com>2010-10-21 17:27:12 +0900
committerPeng Huang <shawn.p.huang@gmail.com>2010-10-21 17:27:12 +0900
commit96b64a2eff1fb4c9bec4e712b47b23a7900f44e7 (patch)
tree3c694d60300ad6598240d7bdab4abb4a3fecee00
parent8c131cfee02c9104495f11456eb40dc162458a2f (diff)
downloadibus-96b64a2eff1fb4c9bec4e712b47b23a7900f44e7.tar.gz
Destroy existing connection before creating a new connection, and only create the fake context once.
BUG=chromium-os:7998 TEST=manual Review URL: http://codereview.appspot.com/2640041
-rw-r--r--client/gtk2/ibusimcontext.c17
-rw-r--r--src/ibusbus.c19
2 files changed, 15 insertions, 21 deletions
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 7eb1b948..3cf7019a 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -83,6 +83,7 @@ static guint _signal_retrieve_surrounding_id = 0;
static const gchar *_no_snooper_apps = NO_SNOOPER_APPS;
static gboolean _use_key_snooper = ENABLE_SNOOPER;
+static guint _key_snooper_id = 0;
static GtkIMContext *_focus_im_context = NULL;
static IBusInputContext *_fake_context = NULL;
@@ -164,7 +165,7 @@ ibus_im_context_register_type (GTypeModule *type_module)
(GInstanceInitFunc) ibus_im_context_init,
};
- if (! _ibus_type_im_context ) {
+ if (!_ibus_type_im_context) {
if (type_module) {
_ibus_type_im_context =
g_type_module_register_type (type_module,
@@ -354,15 +355,19 @@ ibus_im_context_class_init (IBusIMContextClass *klass)
if (_bus == NULL) {
ibus_set_display (gdk_display_get_name (gdk_display_get_default ()));
_bus = ibus_bus_new();
- }
- if (ibus_bus_is_connected (_bus)) {
- _create_fake_input_context ();
+ /* init the global fake context */
+ if (ibus_bus_is_connected (_bus)) {
+ _create_fake_input_context ();
+ }
+
+ g_signal_connect (_bus, "connected", G_CALLBACK (_bus_connected_cb), NULL);
}
- g_signal_connect (_bus, "connected", G_CALLBACK (_bus_connected_cb), NULL);
+
/* always install snooper */
- gtk_key_snooper_install (_key_snooper_cb, NULL);
+ if (_key_snooper_id == 0)
+ _key_snooper_id = gtk_key_snooper_install (_key_snooper_cb, NULL);
}
static void
diff --git a/src/ibusbus.c b/src/ibusbus.c
index 60a4a37a..ea5e0d60 100644
--- a/src/ibusbus.c
+++ b/src/ibusbus.c
@@ -192,22 +192,12 @@ ibus_bus_connect (IBusBus *bus)
IBusBusPrivate *priv;
priv = IBUS_BUS_GET_PRIVATE (bus);
-#if 0
- socket_path = ibus_get_socket_path ();
-
- if (stat (socket_path, &buf) != 0) {
- g_warning ("Can not get stat from %s!", socket_path);
- return;
- }
- if (buf.st_uid != ibus_get_daemon_uid ()) {
- g_warning ("The owner of %s is not %s!", socket_path, ibus_get_user_name ());
- return;
- }
-
+ /* destry old connection at first */
if (priv->connection != NULL) {
- ibus_object_destroy ((IBusObject *) priv->connection);
+ ibus_object_destroy ((IBusObject *)priv->connection);
+ g_assert (priv->connection == NULL);
}
-#endif
+
if (ibus_get_address () != NULL) {
priv->connection = ibus_connection_open (ibus_get_address ());
}
@@ -286,7 +276,6 @@ ibus_bus_init (IBusBus *bus)
ibus_bus_connect (bus);
-
file = g_file_new_for_path (ibus_get_socket_path ());
priv->monitor = g_file_monitor_file (file, 0, NULL, NULL);