* Boston, MA 02111-1307, USA.
*/
-#include "accessible-register.h"
-#include "accessible-marshaller.h"
-
#include "spi-common/spi-dbus.h"
-#define INVALID_PATH "/Invalid"
+#include "accessible-register.h"
+#include "accessible-marshaller.h"
/*---------------------------------------------------------------------------*/
parent = atk_object_get_parent(obj);
if (parent == NULL)
{
- path_parent = g_strdup("/");
+ path_parent = atk_dbus_desktop_object_path ();
}
else
{
path_parent = atk_dbus_object_to_path (parent);
if (!path_parent)
{
- path_parent = g_strdup(INVALID_PATH);
+ /* This should only happen if a widget is re-parented to
+ * an AtkObject that has not been registered and is then
+ * updated. Ideally objects would be de-registered when
+ * they are removed from a registered tree object, but
+ * this would invalidate a huge amount of cache when
+ * re-parenting.
+ */
+#if SPI_ATK_DEBUG
+ g_warning ("AT-SPI: Registered accessible marshalled when parent not registered");
+#endif
+ path_parent = atk_dbus_desktop_object_path ();
}
}
dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
child = atk_object_ref_accessible_child (obj, i);
child_path = atk_dbus_object_to_path (child);
- g_object_unref(G_OBJECT(child));
- if (!G_LIKELY (child_path))
+ if (child_path)
{
- child_path = g_strdup(INVALID_PATH);
+ dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
+ g_free (child_path);
}
- dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
- g_free (child_path);
+ g_object_unref(G_OBJECT(child));
}
}
dbus_message_iter_close_container (&iter_struct, &iter_sub_array);
#include "bridge.h"
#include "accessible-register.h"
-#define ATK_BRIDGE_OBJECT_PATH_PREFIX "/org/freedesktop/atspi/accessible"
-#define ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE ATK_BRIDGE_OBJECT_PATH_PREFIX "/%d"
-#define ATK_BRIDGE_PATH_PREFIX_LENGTH 33
-
/*
* This module is responsible for keeping track of all the AtkObjects in
* the application, so that they can be accessed remotely and placed in
*
* To access an AtkObject remotely we need to provide a D-Bus object
* path for it. The D-Bus object paths used have a standard prefix
- * (ATK_BRIDGE_OBJECT_PATH_PREFIX). Appended to this prefix is a string
+ * (SPI_ATK_OBJECT_PATH_PREFIX). Appended to this prefix is a string
* representation of an integer reference. So to access an AtkObject
* remotely we keep a Hashtable that maps the given reference to
* the AtkObject pointer. An object in this hash table is said to be 'registered'.
/*
* FIXME
*
- * While traversing the ATK tree we may modify it unintentionally.
- * This is either a bug in the Gail implementation or this module.
- * If a change is caused that recurses, via a signal into this module
- * we should catch it.
+ * This code seems very brittle.
+ * I would prefer changes to be made to
+ * gail and the ATK interface so that all Accessible
+ * objects are registered with an exporting module.
*
- * Things could also be changed that do not cause signal emission,
- * but do cause a failure. Not sure what these would be.
+ * This is the same system as Qt has with the QAccessibleBridge
+ * and QAccessibleBridgePlugin. It entails some rather
+ * large structural changes to ATK though:
*
- * The other option is that there are threads that modify the GUI.
- * This IS A BUG IN THE PROGRAM. But it may happen. If seeing very
- * odd bugs change this to take the GDK lock. Just to make sure.
+ * Removing infinite spaces (Child access no longer references child).
+ * Removing lazy creation of accessible objects.
*/
+#define SPI_ATK_OBJECT_PATH_PREFIX "/org/freedesktop/atspi/accessible"
+#define SPI_ATK_OBJECT_PATH_DESKTOP "/root"
+
+#define SPI_ATK_PATH_PREFIX_LENGTH 33
+#define SPI_ATK_OBJECT_REFERENCE_TEMPLATE SPI_ATK_OBJECT_PATH_PREFIX "/%d"
+
+
static GHashTable *ref2ptr = NULL; /* Used for converting a D-Bus path (Reference) to the object pointer */
static guint counter = 1;
static gchar *
ref_to_path (guint ref)
{
- return g_strdup_printf(ATK_BRIDGE_OBJECT_REFERENCE_TEMPLATE, ref);
+ return g_strdup_printf(SPI_ATK_OBJECT_REFERENCE_TEMPLATE, ref);
}
/*---------------------------------------------------------------------------*/
g_assert (path);
- if (strncmp(path, ATK_BRIDGE_OBJECT_PATH_PREFIX, ATK_BRIDGE_PATH_PREFIX_LENGTH) != 0)
+ if (strncmp(path, SPI_ATK_OBJECT_PATH_PREFIX, SPI_ATK_PATH_PREFIX_LENGTH) != 0)
return NULL;
- path += ATK_BRIDGE_PATH_PREFIX_LENGTH; /* Skip over the prefix */
+ path += SPI_ATK_PATH_PREFIX_LENGTH; /* Skip over the prefix */
- if (path[0] == '\0')
+ if (!g_strcmp0 (SPI_ATK_OBJECT_PATH_DESKTOP, path))
return atk_get_root();
if (path[0] != '/')
return NULL;
return ref_to_path (ref);
}
+gchar *
+atk_dbus_desktop_object_path ()
+{
+ return g_strdup (SPI_ATK_OBJECT_PATH_PREFIX SPI_ATK_OBJECT_PATH_DESKTOP);
+}
+
/*---------------------------------------------------------------------------*/
/*
#------------------------------------------------------------------------------
class TestApplicationCache(object):
+ _DESKTOP_PATH = '/org/freedesktop/atspi/accessible/desktop'
+
"""
Test application store, accesses a single application.
provided here so that another one is not created.
"""
# An acc_path of '/' implies the desktop object, whatever the app_name.
- if acc_path == '/':
+ if acc_path == TestApplicationCache._DESKTOP_PATH:
return Desktop(self)
else:
cls = accessible_factory.get_accessible_class(interface)
"""
# An accessible path of '/' implies the desktop object, whatever the application name.
- _DESKTOP_PATH = '/'
+ _DESKTOP_PATH = '/org/freedesktop/atspi/accessible/root'
_APPLICATIONS_ADD = 1
_APPLICATIONS_REMOVE = 0