/*---------------------------------------------------------------------------*/
-#define ITF_EVENT_OBJECT "org.freedesktop.atspi.Event.Object"
-#define ITF_EVENT_WINDOW "org.freedesktop.atspi.Event.Window"
-#define ITF_EVENT_DOCUMENT "org.freedesktop.atspi.Event.Document"
-#define ITF_EVENT_FOCUS "org.freedesktop.atspi.Event.Focus"
+#define ITF_EVENT_OBJECT "org.a11y.atspi.Event.Object"
+#define ITF_EVENT_WINDOW "org.a11y.atspi.Event.Window"
+#define ITF_EVENT_DOCUMENT "org.a11y.atspi.Event.Document"
+#define ITF_EVENT_FOCUS "org.a11y.atspi.Event.Focus"
/*---------------------------------------------------------------------------*/
dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
closure.loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (closure.loop);
+ /* TODO: Remove old AT_SPI_CLIENT name */
+ if (getenv ("AT_SPI_CLIENT") || getenv ("AT_SPI_REENTER_G_MAIN_LOOP"))
+ {
+ g_main_loop_run (closure.loop);
+ }
+ else
+ {
+ closure.reply = NULL;
+ while (!closure.reply)
+ {
+ if (!dbus_connection_read_write_dispatch (spi_global_app_data->bus, 1000))
+ return NULL;
+ }
+ }
g_main_loop_unref (closure.loop);
return closure.reply;
}
/*
+ * Converts names of the form "active-descendant-changed" to
+ * "ActiveDescendantChanged"
+ */
+static gchar *
+ensure_proper_format (const char *name)
+{
+ gchar *ret = (gchar *) g_malloc (strlen (name) * 2 + 2);
+ gchar *p = ret;
+ gboolean need_upper = TRUE;
+
+ if (!ret)
+ return NULL;
+ while (*name)
+ {
+ if (need_upper)
+ {
+ *p++ = toupper (*name);
+ need_upper = FALSE;
+ }
+ else if (*name == '-')
+ need_upper = TRUE;
+ else if (*name == ':')
+ {
+ need_upper = TRUE;
+ *p++ = *name;
+ }
+ else
+ *p++ = *name;
+ name++;
+ }
+ *p = '\0';
+ return ret;
+}
+
+static gboolean
+signal_is_needed (const gchar *klass, const gchar *major, const gchar *minor)
+{
+ gchar *data [4];
+ GList *iter;
+ event_data *evdata;
+ gboolean ret = FALSE;
+ GList *list;
+
+ data [0] = ensure_proper_format (klass + 21);
+ data [1] = ensure_proper_format (major);
+ data [2] = ensure_proper_format (minor);
+ data [3] = NULL;
+
+ /* Hack: events such as "object::text-changed::insert:system" as
+ generated by Gecko */
+ data [2][strcspn (data [2], ":")] = '\0';
+ for (list = spi_global_app_data->events; list; list = list->next)
+ {
+ evdata = list->data;
+ if (spi_event_is_subtype (data, evdata->data))
+ {
+ ret = TRUE;
+ break;
+ }
+ }
+
+ g_free (data [2]);
+ g_free (data [1]);
+ g_free (data [0]);
+ return ret;
+}
+
+/*
* Emits an AT-SPI event.
* AT-SPI events names are split into three parts:
* class:major:minor
if (!minor) minor = "";
if (!type) type = "u";
+ if (!signal_is_needed (klass, major, minor))
+ return;
+
/*
* This is very annoying, but as '-' isn't a legal signal
* name in D-Bus (Why not??!?) The names need converting
dbus_connection_send(bus, sig, NULL);
dbus_message_unref(sig);
+
+ if (g_strcmp0 (cname, "ChildrenChanged") != 0)
+ spi_object_lease_if_needed (G_OBJECT (obj));
}
/*---------------------------------------------------------------------------*/
/*
* Children changed signal converter and forwarder.
*
- * Klass (Interface) org.freedesktop.atspi.Event.Object
+ * Klass (Interface) org.a11y.atspi.Event.Object
* Major is the signal name.
* Minor is 'add' or 'remove'
* detail1 is the index.
/*
* Generic signal converter and forwarder.
*
- * Klass (Interface) org.freedesktop.atspi.Event.Object
+ * Klass (Interface) org.a11y.atspi.Event.Object
* Major is the signal name.
* Minor is NULL.
* detail1 is 0.
}
}
+gboolean
+spi_event_is_subtype (gchar **needle, gchar **haystack)
+{
+ while (*haystack && **haystack)
+ {
+ if (g_strcmp0 (*needle, *haystack))
+ return FALSE;
+ needle++;
+ haystack++;
+ }
+ return TRUE;
+}
+
/*END------------------------------------------------------------------------*/