+2004-06-11 Bill Haneman <bill.haneman@sun.com>
+
+ * atk-bridge/bridge.c:
+ (spi_atk_bridge_do_registration):
+ Register with ATK for AtkComponent:bounds-changed events.
+ (api_atk_bridge_signal_listener):
+ Marshal the AtkRectangle info into the event notification
+ for object:bounds-changed events.
+
+ * libspi/util.c:
+ (spi_init_any_rect): New method, inits a corba struct of
+ type Accessibility_BoundingBox from an AtkRectangle.
+
+ * libspi/spi-private.h: Declared spi_init_any_rect (above).
+
+ * cspi/spi.h:
+ (SPIRect): New struct definition.
+ (SPI_freeRect): New declaration.
+ (AccessibleBoundsChangedEvent_getNewBounds): New, see below.
+
+ * cspi/spi_event.c:
+ (AccessibleBoundsChangedEvent_getNewBounds): New method,
+ implemented. Gets the bounding box data from the CORBA_any
+ associated with a bounds-changed event notification.
+ (cspi_internal_event_get_rect): New, used internally by above method.
+
+ * cspi/spi_main.c:
+ (SPI_freeRect): Implemented this new method, for freeing
+ SPIRect structs.
+
+ * test/event-listener-test.c:
+ (main, report_bounds_event):
+ Added a test for object:bounds-changed events.
+
2004-06-01 Bill Haneman <bill.haneman@sun.com>
* test/login-helper-server-test.c:
*/
static guint atk_signal_link_selected;
+static guint atk_signal_bounds_changed;
static Accessibility_Registry spi_atk_bridge_get_registry (void);
static void spi_atk_bridge_do_registration (void);
ATK_TYPE_OBJECT);
atk_signal_text_changed = g_signal_lookup ("text_changed",
ATK_TYPE_TEXT);
+ atk_signal_bounds_changed = g_signal_lookup ("bounds_changed",
+ ATK_TYPE_COMPONENT);
atk_signal_active_descendant_changed =
g_signal_lookup ("active_descendant_changed",
- ATK_TYPE_OBJECT);
+ ATK_TYPE_OBJECT);
atk_signal_link_selected = g_signal_lookup ("link_selected",
ATK_TYPE_HYPERTEXT);
atk_signal_text_selection_changed = g_signal_lookup ("text_selection_changed",
add_signal_listener ("Gtk:AtkObject:children-changed");
add_signal_listener ("Gtk:AtkObject:visible-data-changed");
add_signal_listener ("Gtk:AtkObject:active-descendant-changed");
+ add_signal_listener ("Gtk:AtkComponent:bounds-changed");
add_signal_listener ("Gtk:AtkSelection:selection-changed");
add_signal_listener ("Gtk:AtkText:text-selection-changed");
add_signal_listener ("Gtk:AtkText:text-changed");
detail1 = g_value_get_int (param_values + 1);
spi_init_any_nil (&any);
}
+ else if (signal_query.signal_id == atk_signal_bounds_changed)
+ {
+ AtkRectangle *atk_rect = NULL;
+
+ if (G_VALUE_HOLDS_BOXED (param_values + 1))
+ atk_rect = g_value_get_boxed (param_values + 1);
+ spi_init_any_rect (&any, atk_rect);
+ }
else if ((signal_query.signal_id == atk_signal_children_changed) && gobject)
{
ao = atk_object_ref_accessible_child (ATK_OBJECT (gobject),
typedef unsigned long AccessibleKeyEventMask;
typedef unsigned long AccessibleDeviceEventMask;
+typedef struct {
+ long x;
+ long y;
+ long width;
+ long height;
+} SPIRect;
+
/**
*AccessibleComponentLayer:
*@SPI_LAYER_INVALID: The layer cannot be determined or is somehow undefined.
char * AccessibleDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e);
char * AccessibleNameChangedEvent_getNameString (const AccessibleEvent *e);
+SPIRect * AccessibleBoundsChangedEvent_getNewBounds (const AccessibleEvent *e);
/* Misc methods and error handling */
void SPI_freeString (char *s);
char* SPI_dupString (char *s);
+void SPI_freeRect (SPIRect *rect);
+
SPIBoolean SPI_exceptionHandlerPush (SPIExceptionHandler *handler);
SPIExceptionHandler* SPI_exceptionHandlerPop (void);
return NULL;
}
+static SPIRect *
+cspi_internal_event_get_rect (const InternalEvent *e)
+{
+ CORBA_any *any;
+ g_return_val_if_fail (e, NULL);
+ g_return_val_if_fail (e->data, NULL);
+ any = (CORBA_any *) e->data;
+ if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_BoundingBox, NULL))
+ {
+ SPIRect *rect = g_new (SPIRect, 1);
+ Accessibility_BoundingBox *bounds = (Accessibility_BoundingBox *) any->_value;
+ rect->x = bounds->x;
+ rect->y = bounds->y;
+ rect->width = bounds->width;
+ rect->height = bounds->height;
+ return rect;
+ }
+ else
+ {
+#ifdef EVENT_CONTEXT_DEBUG
+ fprintf (stderr, "requested string, TC is not TC_Accessible_RectBounds! (%u)\n",
+ (unsigned) any->_type);
+#endif
+ return NULL;
+ }
+}
+
/**
* AccessibleTextChangedEvent_getChangeString:
* @e: a pointer to the #AccessibleEvent being queried.
return cspi_internal_event_get_text (foo);
}
+/**
+ * AccessibleBoundsChangedEvent_getNewBounds:
+ * @e: a pointer to the #AccessibleEvent being queried.
+ *
+ * Queries an #AccessibleEvent of type "object:bounds-changed",
+ * returning a pointer to an SPIRect structure containing the
+ * new bounds, or NULL on error.
+ * The returned structure should be freed with SPI_freeRect when
+ * the caller has finished referencing it.
+ *
+ * Returns: a pointer to an SPIRect defining the new object bounds.
+ **/
+SPIRect *
+AccessibleBoundsChangedEvent_getNewBounds (const AccessibleEvent *e)
+{
+ const InternalEvent *foo = (InternalEvent *) e;
+ /* TODO: check the event type. */
+ return cspi_internal_event_get_rect (foo);
+}
+
static gint
cspi_event_compare (gconstpointer p1, gconstpointer p2)
{
}
/**
+ * SPI_freeRect:
+ * @r: a pointer to an SPIRect returned from another at-spi call.
+ *
+ * Free a SPIRect structure returned from an at-spi call. Clients of
+ * at-spi should use this function instead of free () or g_free().
+ * A NULL rect @r will be silently ignored.
+ * This API should not be used to free data
+ * from other libraries or allocated by the client.
+ **/
+void
+SPI_freeRect (SPIRect *r)
+{
+ if (r)
+ {
+ /* err, okay, in this case the client _could_
+ have called g_free, but we don't want to guarantee it */
+ g_free (r);
+ }
+}
+
+/**
* DOCUMENT_ME!
**/
char *
#define SPI_PRIVATE_H_
#include <glib/glist.h>
+#include <atk/atk.h>
#include <orbit/orbit.h>
G_BEGIN_DECLS
void spi_init_any_nil (CORBA_any *any);
void spi_init_any_string (CORBA_any *any, char **string);
void spi_init_any_object (CORBA_any *any, CORBA_Object *o);
+void spi_init_any_rect (CORBA_any *any, AtkRectangle *rect);
G_END_DECLS
#include <glib/gmessages.h>
#include <glib/gslist.h>
+#include <Accessibility.h>
#include "spi-private.h"
any->_value = &spi_atk_bridge_null_string;
any->_release = FALSE;
}
+
+void
+spi_init_any_rect (CORBA_any *any, AtkRectangle *rect)
+{
+ Accessibility_BoundingBox *box = Accessibility_BoundingBox__alloc ();
+ box->x = rect->x;
+ box->y = rect->y;
+ box->width = rect->width;
+ box->height = rect->height;
+ any->_type = TC_Accessibility_BoundingBox;
+ any->_value = box;
+ any->_release = TRUE;
+}
static void traverse_accessible_tree (Accessible *accessible);
static void report_event (const AccessibleEvent *event, void *user_data);
+static void report_bounds_event (const AccessibleEvent *event, void *user_data);
static void report_detail_event (const AccessibleEvent *event, void *user_data);
static void report_detail1_event (const AccessibleEvent *event, void *user_data);
static void report_text_event (const AccessibleEvent *event, void *user_data);
static AccessibleEventListener *generic_listener;
static AccessibleEventListener *specific_listener;
+static AccessibleEventListener *bounds_listener;
static AccessibleEventListener *detail1_listener;
static AccessibleEventListener *test_listener;
static AccessibleEventListener *text_listener;
report_event, NULL);
specific_listener = SPI_createAccessibleEventListener (
report_detail_event, NULL);
+ bounds_listener = SPI_createAccessibleEventListener (
+ report_bounds_event, NULL);
text_listener = SPI_createAccessibleEventListener (
report_text_event, NULL);
text_selection_listener = SPI_createAccessibleEventListener (
"object:model-changed");
SPI_registerGlobalEventListener (detail1_listener,
"object:link-selected");
+ SPI_registerGlobalEventListener (bounds_listener,
+ "object:bounds-changed");
SPI_registerGlobalEventListener (window_listener,
"window:minimize");
SPI_registerGlobalEventListener (window_listener,
}
void
+report_bounds_event (const AccessibleEvent *event, void *user_data)
+{
+ char *s = Accessible_getName (event->source);
+ SPIRect *bounds = AccessibleBoundsChangedEvent_getNewBounds (event);
+ if (!bounds) fprintf (stderr, "bounds-changed event with no bounds?\n");
+ fprintf (stderr, "(bounds-changed) %s %s %d,%d - %d,%d\n", event->type, s,
+ bounds->x, bounds->y, bounds->x + bounds->width, bounds->y + bounds->height);
+ SPI_freeRect (bounds);
+ if (s) SPI_freeString (s);
+}
+
+void
report_text_event (const AccessibleEvent *event, void *user_data)
{
char *s = Accessible_getName (event->source);