Add a gsettings key to specify the location of libatk-bridge.so
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index 28de5ff..9e6e83e 100644 (file)
@@ -55,12 +55,15 @@ typedef struct _SpiReentrantCallClosure
 static void
 switch_main_context (GMainContext *cnx)
 {
+#ifndef DISABLE_P2P
+/* This code won't work on dbus-glib earlier than 0.9.0 because of FDO#30574 */
   GList *list;
 
   dbus_server_setup_with_g_main (spi_global_app_data->server, cnx);
   dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx);
   for (list = spi_global_app_data->direct_connections; list; list = list->next)
     dbus_connection_setup_with_g_main (list->data, cnx);
+#endif
 }
 
 static void
@@ -78,9 +81,12 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
 {
   DBusPendingCall *pending;
   SpiReentrantCallClosure closure;
+  GMainContext *main_context;
 
-  closure.loop = g_main_loop_new (spi_global_app_data->main_context, FALSE);
-  switch_main_context (spi_global_app_data->main_context);
+  main_context = (g_getenv ("AT_SPI_CLIENT") ? NULL :
+                  spi_global_app_data->main_context);
+  closure.loop = g_main_loop_new (main_context, FALSE);
+  switch_main_context (main_context);
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
     {
@@ -340,6 +346,9 @@ signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
   gboolean ret = FALSE;
   GList *list;
 
+  if (!spi_global_app_data->events_initialized)
+    return TRUE;
+
   data [0] = ensure_proper_format (klass + 21);
   data [1] = ensure_proper_format (major);
   data [2] = ensure_proper_format (minor);
@@ -408,7 +417,6 @@ emit_event (AtkObject  *obj,
    */
   cname = signal_name_to_dbus (major);
   sig = dbus_message_new_signal(path, klass, cname);
-  g_free(cname);
 
   dbus_message_iter_init_append(sig, &iter);
 
@@ -423,6 +431,8 @@ emit_event (AtkObject  *obj,
 
   if (g_strcmp0 (cname, "ChildrenChanged") != 0)
     spi_object_lease_if_needed (G_OBJECT (obj));
+
+  g_free(cname);
 }
 
 /*---------------------------------------------------------------------------*/