2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
6 * Copyright 2001, 2002, 2003 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include <cspi/spi-private.h>
25 #include <cspi/bonobo/cspi-bonobo-listener.h>
27 static GSList *_cspi_event_queue = NULL;
30 * SPI_freeAccessibleKeySet:
31 * @keyset: An AccessibleKeyset to free.
33 * Release the memory used by an AccessibleKeySet.
37 SPI_freeAccessibleKeySet (AccessibleKeySet *keyset)
40 g_free (keyset->keysyms);
41 g_free (keyset->keycodes);
42 while (keyset->keystrings [i])
44 g_free (keyset->keystrings [i++]);
46 g_free (keyset->keystrings);
51 * SPI_createAccessibleKeySet:
52 * @len: the number of key values in the key set.
53 * @keysyms: a UTF-8 string containing symbolic key values to be matched, or NULL if
54 * matching is performed against other key values instead.
55 * @keycodes: an array of unsigned short values which are the hardware keycodes
56 * to be matched, or NULL if the keyset is specified solely by keysyms
58 * @keystrings: an array of null-terminated character strings which specify key
59 * name values to match, or NULL if the keyset is specified solely by
60 * keycodes and/or keysyms.
62 * Create a new #AccessibleKeySet of a specified length.
63 * A KeySet is used typically to match key event values, and a matches are made
64 * using the following criteria: a match exists with a key event if all non-null
65 * i-th members of the keyset match the key event.
66 * If both keystring and keysym values are NULL, a keycode value match is
67 * forced, thus the match for keysym=0, keycode=0, keystring=NULL is
70 * Returns: a pointer to a newly-created #AccessibleKeySet.
74 SPI_createAccessibleKeySet (int len, const char *keysyms, short *keycodes,
75 const char **keystrings)
77 AccessibleKeySet *keyset = g_new0 (AccessibleKeySet, 1);
78 int i, keysym_len = 0;
79 const char *keysym_ptr = keysyms;
81 keyset->keysyms = g_new0 (unsigned long, len);
82 keyset->keycodes = g_new0 (unsigned short, len);
83 keyset->keystrings = g_new0 (char *, len);
86 keysym_len = g_utf8_strlen (keysyms, -1);
88 for (i = 0; i < len; ++i)
92 keyset->keysyms [i] = (unsigned long) g_utf8_get_char (keysym_ptr);
93 keysym_ptr = g_utf8_find_next_char (keysym_ptr, NULL);
97 keyset->keysyms [i] = 0;
101 keyset->keycodes [i] = keycodes [i];
105 keyset->keystrings [i] = g_strdup (keystrings [i]);
112 * SPI_createAccessibleEventListener:
113 * @callback : an #AccessibleEventListenerCB callback function, or NULL.
114 * @user_data: a pointer to data which will be passed to the callback when invoked.
116 * Create a new #AccessibleEventListener with a specified (in-process) callback function.
118 * Returns: a pointer to a newly-created #AccessibleEventListener.
121 AccessibleEventListener *
122 SPI_createAccessibleEventListener (AccessibleEventListenerCB callback,
125 AccessibleEventListener *listener = cspi_event_listener_new ();
128 AccessibleEventListener_addCallback (listener, callback, user_data);
134 * AccessibleEventListener_addCallback:
135 * @listener: the #AccessibleEventListener instance to modify.
136 * @callback: an #AccessibleEventListenerCB function pointer.
137 * @user_data: a pointer to data which will be passed to the callback when invoked.
139 * Add an in-process callback function to an existing AccessibleEventListener.
140 * Note that the callback function must live in the same address
141 * space as the AccessibleEventListener implementation code, thus one should not
142 * use this function to attach callbacks to a 'remote' event listener
143 * (that is, one that was not created by a client call to
144 * createAccessibleEventListener ();
146 * Returns: #TRUE if successful, otherwise #FALSE.
150 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
151 AccessibleEventListenerCB callback,
154 cspi_event_listener_add_cb (listener, callback, user_data);
159 * AccessibleEventListener_unref:
160 * @listener: a pointer to the #AccessibleEventListener being operated on.
162 * Decrements an #AccessibleEventListener's reference count.
165 AccessibleEventListener_unref (AccessibleEventListener *listener)
167 cspi_event_listener_unref (listener);
171 * AccessibleEventListener_removeCallback:
172 * @listener: the #AccessibleEventListener instance to modify.
173 * @callback: an #AccessibleEventListenerCB function pointer.
175 * Remove an in-process callback function from an existing AccessibleEventListener.
177 * Returns: #TRUE if successful, otherwise #FALSE.
181 AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
182 AccessibleEventListenerCB callback)
184 cspi_event_listener_remove_cb (listener, callback);
189 * SPI_createAccessibleKeystrokeListener:
190 * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
191 * @user_data: a pointer to data which will be passed to the callback when invoked.
193 * Create a new #AccessibleKeystrokeListener with a specified callback function.
195 * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
198 AccessibleKeystrokeListener *
199 SPI_createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
202 AccessibleDeviceListener *listener = cspi_device_listener_new ();
205 AccessibleDeviceListener_addCallback (listener, callback, user_data);
211 * AccessibleKeystrokeListener_addCallback:
212 * @listener: the #AccessibleKeystrokeListener instance to modify.
213 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
214 * @user_data: a pointer to data which will be passed to the callback when invoked.
216 * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
218 * Returns: #TRUE if successful, otherwise #FALSE.
222 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
223 AccessibleKeystrokeListenerCB callback,
226 cspi_device_listener_add_cb (listener, callback, user_data);
231 * AccessibleKeystrokeListener_removeCallback:
232 * @listener: the #AccessibleKeystrokeListener instance to modify.
233 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
235 * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
237 * Returns: #TRUE if successful, otherwise #FALSE.
241 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
242 AccessibleKeystrokeListenerCB callback)
244 cspi_device_listener_remove_cb (listener, callback);
249 * AccessibleKeystrokeListener_unref:
250 * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
252 * Decrements an #AccessibleKeystrokeListener's reference count.
255 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
257 cspi_device_listener_unref (listener);
261 * SPI_createAccessibleDeviceListener:
262 * @callback : an #AccessibleDeviceListenerCB callback function, or NULL.
263 * @user_data: a pointer to data which will be passed to the callback when invoked.
265 * Create a new #AccessibleDeviceListener with a specified callback function.
267 * Returns: a pointer to a newly-created #AccessibleDeviceListener.
270 AccessibleDeviceListener *
271 SPI_createAccessibleDeviceListener (AccessibleDeviceListenerCB callback,
274 AccessibleDeviceListener *listener = cspi_device_listener_new ();
277 AccessibleDeviceListener_addCallback (listener, callback, user_data);
283 * AccessibleDeviceListener_addCallback:
284 * @listener: the #AccessibleDeviceListener instance to modify.
285 * @callback: an #AccessibleDeviceListenerCB function pointer.
286 * @user_data: a pointer to data which will be passed to the callback when invoked.
288 * Add an in-process callback function to an existing #AccessibleDeviceListener.
290 * Returns: #TRUE if successful, otherwise #FALSE.
294 AccessibleDeviceListener_addCallback (AccessibleDeviceListener *listener,
295 AccessibleDeviceListenerCB callback,
298 cspi_device_listener_add_cb (listener, callback, user_data);
303 * AccessibleDeviceListener_removeCallback:
304 * @listener: the #AccessibleDeviceListener instance to modify.
305 * @callback: an #AccessibleDeviceListenerCB function pointer.
307 * Remove an in-process callback function from an existing #AccessibleDeviceListener.
309 * Returns: #TRUE if successful, otherwise #FALSE.
313 AccessibleDeviceListener_removeCallback (AccessibleDeviceListener *listener,
314 AccessibleDeviceListenerCB callback)
316 cspi_device_listener_remove_cb (listener, callback);
321 * AccessibleDeviceListener_unref:
322 * @listener: a pointer to the #AccessibleDeviceListener being operated on.
324 * Decrements an #AccessibleDeviceListener's reference count.
327 AccessibleDeviceListener_unref (AccessibleDeviceListener *listener)
329 cspi_device_listener_unref (listener);
333 cspi_internal_event_get_text (const InternalEvent *e)
336 g_return_val_if_fail (e, NULL);
337 g_return_val_if_fail (e->data, NULL);
338 any = (CORBA_any *) e->data;
339 if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL))
341 Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
342 if (CORBA_TypeCode_equal (details->any_data._type, TC_CORBA_string, cspi_ev()))
343 return CORBA_string_dup (* (char **) (details->any_data._value));
345 return CORBA_string_dup ("");
346 return CORBA_string_dup (* (char **) (details->any_data._value));
348 else if (CORBA_TypeCode_equivalent (any->_type, TC_CORBA_string, NULL))
350 return CORBA_string_dup (* (char **) any->_value);
354 #ifdef EVENT_CONTEXT_DEBUG
355 fprintf (stderr, "requested string, TC is not TC_CORBA_string! (%u)\n",
356 (unsigned) any->_type);
363 cspi_internal_event_get_object (const InternalEvent *e)
367 g_return_val_if_fail (e, NULL);
368 g_return_val_if_fail (e->data, NULL);
370 any = (CORBA_any *) e->data;
371 if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL))
373 Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
374 if (CORBA_TypeCode_equal (details->any_data._type, TC_CORBA_Object, cspi_ev()))
375 return cspi_object_take (* (CORBA_Object *) (details->any_data._value));
379 else if (CORBA_TypeCode_equal (any->_type, TC_CORBA_Object, cspi_ev()))
380 return cspi_object_take (* (CORBA_Object *) any->_value);
386 cspi_internal_event_get_rect (const InternalEvent *e)
389 g_return_val_if_fail (e, NULL);
390 g_return_val_if_fail (e->data, NULL);
391 any = (CORBA_any *) e->data;
392 if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_EventDetails, NULL))
394 Accessibility_EventDetails *details = (Accessibility_EventDetails *)any->_value;
395 SPIRect *rect = g_new (SPIRect, 1);
396 if (CORBA_TypeCode_equal (details->any_data._type, TC_Accessibility_BoundingBox, cspi_ev()))
398 Accessibility_BoundingBox *bounds = (Accessibility_BoundingBox *) details->any_data._value;
401 rect->width = bounds->width;
402 rect->height = bounds->height;
408 if (CORBA_TypeCode_equivalent (any->_type, TC_Accessibility_BoundingBox, NULL))
410 SPIRect *rect = g_new (SPIRect, 1);
411 Accessibility_BoundingBox *bounds = (Accessibility_BoundingBox *) any->_value;
414 rect->width = bounds->width;
415 rect->height = bounds->height;
420 #ifdef EVENT_CONTEXT_DEBUG
421 fprintf (stderr, "requested string, TC is not TC_Accessible_RectBounds! (%u)\n",
422 (unsigned) any->_type);
429 * AccessibleEvent_getSourceName:
431 * Get the 'accessible-name' of the object emitting the event.
432 * @event: an #AccessibleEvent to be queried.
434 * Returns: The name of the event source, or NULL if the event source cannot be identified
435 * or does not report a name.
437 char* AccessibleEvent_getSourceName (const AccessibleEvent *e)
439 InternalEvent *ie = (InternalEvent *)e;
440 CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
442 CORBA_TypeCode_equivalent (any->_type,
443 TC_Accessibility_EventDetails, NULL))
445 Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
446 return CORBA_string_dup (details->source_name);
453 * AccessibleEvent_getSourceRole:
455 * Get the #AccessibleRole of the object emitting the event.
456 * @event: an #AccessibleEvent to be queried.
458 * Returns: #AccessibleRole of the event source, or SPI_ROLE_UNKNOWN
459 * if the event source's role is unknown or unspecified.
460 * (Some kinds of events, such as 'mouse:' events or
461 * toolkit events, don't have associated object roles.)
463 AccessibleRole AccessibleEvent_getSourceRole (const AccessibleEvent *e)
465 InternalEvent *ie = (InternalEvent *)e;
466 CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
468 CORBA_TypeCode_equivalent (any->_type,
469 TC_Accessibility_EventDetails, NULL))
471 Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
472 return cspi_role_from_spi_role (details->source_role);
475 return SPI_ROLE_UNKNOWN;
479 * AccessibleEvent_getSourceApplication:
481 * Get the #Application hosting the object which emitted the event.
482 * @event: an #AccessibleEvent to be queried.
484 * Returns: A pointer to the host #Application contining the event source
487 AccessibleApplication* AccessibleEvent_getSourceApplication (const AccessibleEvent *e)
489 InternalEvent *ie = (InternalEvent *)e;
490 CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
492 CORBA_TypeCode_equivalent (any->_type,
493 TC_Accessibility_EventDetails, NULL))
495 Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
496 return cspi_object_take (details->host_application);
503 * AccessibleEvent_getSourceApplication:
505 * Get the host #Application, "accessible name", and #AccessibleRole
506 * of the object which emitted the event.
508 * @event: an #AccessibleEvent to be queried.
510 * Returns: TRUE if the source details were successfully retrieved,
511 * FALSE if they were not, either due to error, incomplete data,
512 * or the fact that the event did not encapsulate the required data.
514 SPIBoolean AccessibleEvent_getSourceDetails (const AccessibleEvent *e,
515 char **name, AccessibleRole *role,
516 AccessibleApplication **app)
518 InternalEvent *ie = (InternalEvent *)e;
519 CORBA_any *any = ((ie && ie->data) ? (CORBA_any *)ie->data : NULL);
521 CORBA_TypeCode_equivalent (any->_type,
522 TC_Accessibility_EventDetails, NULL))
524 Accessibility_EventDetails *details = (Accessibility_EventDetails *) any->_value;
525 *name = CORBA_string_dup (details->source_name);
526 *role = cspi_role_from_spi_role (details->source_role);
527 *app = cspi_object_take (details->host_application);
533 *role = SPI_ROLE_UNKNOWN;
540 * AccessibleTextChangedEvent_getChangeString:
541 * @e: a pointer to the #AccessibleEvent being queried.
543 * Queries an #AccessibleEvent of type "object:text-changed",
544 * returning the text inserted or deleted.
546 * Returns: a UTF-8 text string indicating the text inserted,
547 * deleted, or substituted by this event.
550 AccessibleTextChangedEvent_getChangeString (const AccessibleEvent *e)
552 const InternalEvent *foo = (InternalEvent *) e;
553 /* TODO: check the event type. */
554 return cspi_internal_event_get_text (foo);
558 * AccessibleTextSelectionChangedEvent_getSelectionString:
559 * @e: a pointer to the #AccessibleEvent being queried.
561 * Queries an #AccessibleEvent of type "object:text-selection-changed",
562 * returning the newly added, removed, or modified selection string.
564 * Returns: a UTF-8 text string indicating the recently changed selection.
567 AccessibleTextSelectionChangedEvent_getSelectionString (const AccessibleEvent *e)
569 const InternalEvent *foo = (InternalEvent *) e;
570 /* TODO: check the event type. */
571 return cspi_internal_event_get_text (foo);
575 * AccessibleWindowEvent_getTitleString:
576 * @e: a pointer to the #AccessibleEvent being queried.
578 * Queries an #AccessibleEvent of type "window:",
579 * returning the window title.
581 * Returns: a UTF-8 text string representing the title of the
582 * recently changed window.
585 AccessibleWindowEvent_getTitleString (const AccessibleEvent *e)
587 const InternalEvent *foo = (InternalEvent *) e;
588 /* TODO: check the event type. */
589 return cspi_internal_event_get_text (foo);
593 * AccessibleChildChangedEvent_getChildAccessible:
594 * @e: a pointer to the #AccessibleEvent being queried.
596 * Queries an #AccessibleEvent of type "object:children_changed"
597 * to get a reference to the changed #Accessible.
598 * Note that context #Accessibles are not guaranteed to outlive
599 * event delivery, in which case this call may return %NULL
600 * even if the object existed at the time of dispatch.
602 * Returns: the context #Accessible for the event, or %NULL if
603 * there is no longer a valid context #Accessible
604 * object for the event.
607 AccessibleChildChangedEvent_getChildAccessible (const AccessibleEvent *e)
609 const InternalEvent *foo = (InternalEvent *) e;
610 return (Accessible *) cspi_internal_event_get_object (foo);
614 * AccessibleParentChangedEvent_getParentAccessible:
615 * @e: a pointer to the #AccessibleEvent being queried.
617 * Queries an #AccessibleEvent of type "object:property-change:accessible-parent"
618 * to get a reference to the changed #Accessible.
619 * Note that context #Accessibles are not guaranteed to outlive
620 * event delivery, in which case this call may return %NULL
621 * even if the object existed at the time of dispatch.
623 * Returns: an #Accessible pointer representing the new parent object.
626 AccessibleParentChangedEvent_getParentAccessible (const AccessibleEvent *e)
628 const InternalEvent *foo = (InternalEvent *) e;
629 return (Accessible *) cspi_internal_event_get_object (foo);
633 * AccessibleActiveDescendantChangedEvent_getActiveDescendant:
634 * @e: a pointer to the #AccessibleEvent being queried.
636 * Queries an #AccessibleEvent of type "object:active-descendant-changed"
637 * to get a reference to the changed #Accessible.
638 * Note that context #Accessibles are not guaranteed to outlive
639 * event delivery, in which case this call may return %NULL
640 * even if the object existed at the time of dispatch.
642 * Returns: an #Accessible pointer representing the new active descendant.
645 AccessibleActiveDescendantChangedEvent_getActiveDescendant (const AccessibleEvent *e)
647 const InternalEvent *foo = (InternalEvent *) e;
648 return (Accessible *) cspi_internal_event_get_object (foo);
652 * AccessibleTableSummaryChangedEvent_getSummaryAccessible:
653 * @e: a pointer to the #AccessibleEvent being queried.
655 * Queries an #AccessibleEvent of type "object:property-changed:accessible-table-summary"
656 * to get a reference to the changed #Accessible.
657 * Note that context #Accessibles are not guaranteed to outlive
658 * event delivery, in which case this call may return %NULL
659 * even if the object existed at the time of dispatch.
661 * Returns: an #Accessible pointer representing the new table summary.
664 AccessibleTableSummaryChangedEvent_getSummaryAccessible (const AccessibleEvent *e)
666 const InternalEvent *foo = (InternalEvent *) e;
667 return (Accessible *) cspi_internal_event_get_object (foo);
671 * AccessibleTableHeaderChangedEvent_getHeaderAccessible:
672 * @e: a pointer to the #AccessibleEvent being queried.
674 * Queries an #AccessibleEvent of type
675 * "object:property-changed:accessible-table-row-header" or
676 * "object:property-changed:accessible-table-column-header"
677 * to get a reference to the changed #Accessible.
678 * Note that context #Accessibles are not guaranteed to outlive
679 * event delivery, in which case this call may return %NULL
680 * even if the object existed at the time of dispatch.
682 * Returns: an #Accessible pointer representing the new table header.
685 AccessibleTableHeaderChangedEvent_getHeaderAccessible (const AccessibleEvent *e)
687 const InternalEvent *foo = (InternalEvent *) e;
688 return (Accessible *) cspi_internal_event_get_object (foo);
693 * AccessibleTableCaptionChangedEvent_getCaptionString:
694 * @e: a pointer to the #AccessibleEvent being queried.
696 * Queries an #AccessibleEvent of type
697 * "object:property-changed:accessible-table-caption-object"
698 * returning the text in the caption, if present.
700 * Returns: a UTF-8 text string indicating the text in the caption.
703 AccessibleTableCaptionChangedEvent_getCaptionString (const AccessibleEvent *e)
705 const InternalEvent *foo = (InternalEvent *) e;
706 /* TODO: check the event type. */
707 return cspi_internal_event_get_text (foo);
711 * AccessibleTableRowDescriptionChangedEvent_getDescriptionString:
712 * @e: a pointer to the #AccessibleEvent being queried.
714 * Queries an #AccessibleEvent of type
715 * "object:property-changed:accessible-table-row-description"
716 * returning the new table row description.
718 * Returns: a UTF-8 text string representing the recently changed
719 * table row description
722 AccessibleTableRowDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
724 const InternalEvent *foo = (InternalEvent *) e;
725 /* TODO: check the event type. */
726 return cspi_internal_event_get_text (foo);
730 * AccessibleTableColumnDescriptionChangedEvent_getDescriptionString:
731 * @e: a pointer to the #AccessibleEvent being queried.
733 * Queries an #AccessibleEvent of type
734 * "object:property-changed:accessible-table-column-description"
735 * returning the new table column description.
737 * Returns: a UTF-8 text string representing the recently changed
738 * table column description
741 AccessibleTableColumnDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
743 const InternalEvent *foo = (InternalEvent *) e;
744 /* TODO: check the event type. */
745 return cspi_internal_event_get_text (foo);
749 * AccessibleDescriptionChangedEvent_getDescriptionString:
750 * @e: a pointer to the #AccessibleEvent being queried.
752 * Queries an #AccessibleEvent of type
753 * "object:property-changed:accessible-description"
754 * returning the new description.
756 * Returns: a UTF-8 text string representing the recently changed
760 AccessibleDescriptionChangedEvent_getDescriptionString (const AccessibleEvent *e)
762 const InternalEvent *foo = (InternalEvent *) e;
763 /* TODO: check the event type. */
764 return cspi_internal_event_get_text (foo);
768 * AccessibleBoundsChangedEvent_getNewBounds:
769 * @e: a pointer to the #AccessibleEvent being queried.
771 * Queries an #AccessibleEvent of type "object:bounds-changed",
772 * returning a pointer to an SPIRect structure containing the
773 * new bounds, or NULL on error.
774 * The returned structure should be freed with SPI_freeRect when
775 * the caller has finished referencing it.
777 * Returns: a pointer to an SPIRect defining the new object bounds.
780 AccessibleBoundsChangedEvent_getNewBounds (const AccessibleEvent *e)
782 const InternalEvent *foo = (InternalEvent *) e;
783 /* TODO: check the event type. */
784 return cspi_internal_event_get_rect (foo);
788 cspi_event_compare (gconstpointer p1, gconstpointer p2)
790 const InternalEvent *e1 = p1, *e2 = p2;
791 return (gint) ((long) e2->id - (long) e1->id);
794 static InternalEvent *
795 cspi_internal_event_lookup (const InternalEvent *e)
797 InternalEvent *internal = NULL;
799 g_slist_find_custom (_cspi_event_queue, e, cspi_event_compare);
805 static const InternalEvent *
806 cspi_internal_event_check (const AccessibleEvent *e)
808 InternalEvent *internal = (InternalEvent *) e;
809 if (internal->magic == SPI_INTERNAL_EVENT_MAGIC)
815 static InternalEvent *
816 cspi_internal_event_add (const InternalEvent *e)
818 _cspi_event_queue = g_slist_prepend (_cspi_event_queue, (gpointer) e);
819 return (InternalEvent *) e;
823 cspi_internal_event_remove (const InternalEvent *e)
825 GSList *link = g_slist_find_custom (_cspi_event_queue, e, cspi_event_compare);
827 _cspi_event_queue = g_slist_remove_link (_cspi_event_queue, link);
831 * AccessibleNameChangedEvent_getNameString:
832 * @e: a pointer to the #AccessibleEvent being queried.
834 * Queries an #AccessibleEvent of type "object:property-change:accessible_name:",
835 * returning the name.
837 * Returns: a UTF-8 text string representing the name of the
838 * object which recently changed.
841 AccessibleNameChangedEvent_getNameString (const AccessibleEvent *e)
843 const InternalEvent *foo = (InternalEvent *) e;
844 return cspi_internal_event_get_text (foo);
848 * AccessibleEvent_ref:
849 * @e: a pointer to the #AccessibleEvent being referenced.
851 * Increments by 1 the reference count of the event
853 * Returns: TRUE if the function succeeded; FALSE if the pointer is not a
857 AccessibleEvent_ref (const AccessibleEvent *e)
859 const InternalEvent *private = cspi_internal_event_check (e);
862 InternalEvent *event = cspi_internal_event_lookup (private);
864 * put event in the cache if it's not there already,
865 * and increment refcount
869 event = cspi_internal_event_add (private);
879 * AccessibleEvent_unref:
880 * @e: a pointer to the #AccessibleEvent being referenced.
882 * Decrements by 1 the reference count of the event. The event is destroyed
883 * when the reference count recahes zero.
887 AccessibleEvent_unref (const AccessibleEvent *e)
889 const InternalEvent *private = cspi_internal_event_check (e);
890 /* decrement refcount and remove if appropriate */
893 InternalEvent *event = cspi_internal_event_lookup (private);
897 if (event->ref_count < 1)
899 cspi_internal_event_remove (event);
900 g_free ((gpointer)e->type);
901 Accessible_unref (e->source);
902 CORBA_free (event->data);
903 g_free ((gpointer)e);