Release v2.11.3
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index 859d399..fa7cbbd 100644 (file)
@@ -67,6 +67,7 @@ switch_main_context (GMainContext *cnx)
   if (spi_global_app_data->server)
     atspi_dbus_server_setup_with_g_main (spi_global_app_data->server, cnx);
   atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx);
+  atspi_set_main_context (cnx);
   for (list = spi_global_app_data->direct_connections; list; list = list->next)
     atspi_dbus_connection_setup_with_g_main (list->data, cnx);
 }
@@ -87,8 +88,8 @@ timeout_reply (void *data)
 {
   SpiReentrantCallClosure *closure = data;
 
-  if (!dbus_connection_get_is_connected (closure->bus))
-    g_main_loop_quit (closure->loop);
+  switch_main_context (NULL);
+  g_main_loop_quit (closure->loop);
   closure->timeout = -1;
   return FALSE;
 }
@@ -98,15 +99,12 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
 {
   DBusPendingCall *pending;
   SpiReentrantCallClosure closure;
-  GMainContext *main_context;
   GSource *source;
 
-  main_context = (g_getenv ("AT_SPI_CLIENT") ? NULL :
-                  spi_global_app_data->main_context);
   closure.bus = bus;
-  closure.loop = g_main_loop_new (main_context, FALSE);
+  closure.loop = g_main_loop_new (spi_global_app_data->main_context, FALSE);
   closure.reply = NULL;
-  switch_main_context (main_context);
+  switch_main_context (spi_global_app_data->main_context);
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, 9000) || !pending)
     {
@@ -116,13 +114,15 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
   dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
   source = g_timeout_source_new (500);
   g_source_set_callback (source, timeout_reply, &closure, NULL);
-  closure.timeout = g_source_attach (source, main_context);
+  closure.timeout = g_source_attach (source, spi_global_app_data->main_context);
   g_source_unref (source);
   g_main_loop_run  (closure.loop);
   if (closure.timeout != -1)
     g_source_destroy (source);
   
   g_main_loop_unref (closure.loop);
+  if (!closure.reply)
+    dbus_pending_call_cancel (pending);
   return closure.reply;
 }
 
@@ -140,7 +140,6 @@ Accessibility_DeviceEventController_NotifyListenersSync (const
                                                          * key_event)
 {
   DBusMessage *message;
-  DBusError error;
   dbus_bool_t consumed = FALSE;
 
   message =
@@ -149,7 +148,6 @@ Accessibility_DeviceEventController_NotifyListenersSync (const
                                   ATSPI_DBUS_INTERFACE_DEC,
                                   "NotifyListenersSync");
 
-  dbus_error_init (&error);
   if (spi_dbus_marshal_deviceEvent (message, key_event))
     {
       DBusMessage *reply =
@@ -158,8 +156,12 @@ Accessibility_DeviceEventController_NotifyListenersSync (const
         {
           DBusError error;
           dbus_error_init (&error);
-          dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN, &consumed,
-                                 DBUS_TYPE_INVALID);
+          if (!dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN,
+              &consumed, DBUS_TYPE_INVALID))
+            {
+              /* TODO: print a warning */
+              dbus_error_free (&error);
+            }
           dbus_message_unref (reply);
         }
     }
@@ -371,7 +373,11 @@ signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
    * TODO: FOr 2.2, have at-spi2-core define a special "cache listener" for
    * this instead, so that we don't send these if no one is listening */
   if (!g_strcmp0 (data [1], "ChildrenChanged") ||
-      !g_strcmp0 (data [1], "PropertyChange") ||
+      ((!g_strcmp0 (data [1], "PropertyChange")) &&
+       (!g_strcmp0 (data [2], "accessible-name") ||
+        !g_strcmp0 (data [2], "accessible-description") ||
+        !g_strcmp0 (data [2], "accessible-parent") ||
+        !g_strcmp0 (data [2], "accessible-role"))) ||
       !g_strcmp0 (data [1], "StateChanged"))
   {
     g_free (data [2]);
@@ -680,6 +686,7 @@ window_event_listener (GSignalInvocationHint * signal_hint,
  * Gtk:AtkDocument:load-complete ->  document:load-complete
  * Gtk:AtkDocument:load-stopped  ->  document:load-stopped
  * Gtk:AtkDocument:reload        ->  document:reload
+ * Gtk:AtkDocument:page-changed  ->  document:page-changed
  */
 static gboolean
 document_event_listener (GSignalInvocationHint * signal_hint,
@@ -689,13 +696,18 @@ document_event_listener (GSignalInvocationHint * signal_hint,
   AtkObject *accessible;
   GSignalQuery signal_query;
   const gchar *name, *s;
+  gint detail1 = 0;
 
   g_signal_query (signal_hint->signal_id, &signal_query);
   name = signal_query.signal_name;
 
+  if (n_param_values > 0) // on the case of page-changed
+    if (G_VALUE_TYPE (&param_values[1]) == G_TYPE_INT)
+      detail1 = g_value_get_int (&param_values[1]);
+
   accessible = ATK_OBJECT (g_value_get_object (&param_values[0]));
   s = atk_object_get_name (accessible);
-  emit_event (accessible, ITF_EVENT_DOCUMENT, name, "", 0, 0,
+  emit_event (accessible, ITF_EVENT_DOCUMENT, name, "", detail1, 0,
               DBUS_TYPE_STRING_AS_STRING, s, append_basic);
 
   return TRUE;
@@ -1153,6 +1165,8 @@ spi_atk_register_event_listeners (void)
   add_signal_listener (document_event_listener, "Gtk:AtkDocument:reload");
   add_signal_listener (document_event_listener,
                        "Gtk:AtkDocument:load-stopped");
+  add_signal_listener (document_event_listener,
+                       "Gtk:AtkDocument:page-changed");
   /* TODO Fake this event on the client side */
   add_signal_listener (state_event_listener, "Gtk:AtkObject:state-change");
   /* TODO */