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;
(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,
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
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 ());
}
ibus_bus_connect (bus);
-
file = g_file_new_for_path (ibus_get_socket_path ());
priv->monitor = g_file_monitor_file (file, 0, NULL, NULL);