From a0661d5d4128769f2544d24430c80dc440bfdbba Mon Sep 17 00:00:00 2001 From: billh Date: Wed, 28 Nov 2001 21:48:07 +0000 Subject: [PATCH] Merged Michael's branch back into HEAD, and fixed a number of reference counting issues. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@123 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 155 ++++++++++++++++++++ at-bridge/bridge.c | 5 +- atk-bridge/bridge.c | 5 +- configure.in | 2 +- cspi/Makefile.am | 10 +- cspi/bonobo/cspi-bonobo-listener.c | 6 +- cspi/bonobo/cspi-bonobo-listener.h | 1 + cspi/spi-impl.h | 50 +++---- cspi/spi-listener-impl.c | 6 +- cspi/spi-listener-impl.h | 1 + cspi/spi-listener.h | 32 +++-- cspi/spi-private.h | 48 ++++--- cspi/spi-util.c | 5 +- cspi/spi.h | 14 -- cspi/spi_accessible.c | 281 +++++++++++++++---------------------- cspi/spi_action.c | 25 ++-- cspi/spi_application.c | 10 +- cspi/spi_component.c | 39 ++--- cspi/spi_editabletext.c | 32 ++--- cspi/spi_event.c | 33 +++-- cspi/spi_hyperlink.c | 22 +-- cspi/spi_hypertext.c | 14 +- cspi/spi_image.c | 14 +- cspi/spi_main.c | 135 ++++++++++++++---- cspi/spi_registry.c | 81 ++++++----- cspi/spi_selection.c | 28 ++-- cspi/spi_table.c | 72 +++++----- cspi/spi_text.c | 68 ++++----- cspi/spi_value.c | 14 +- libspi/accessible.c | 11 +- libspi/accessibleeventlistener.c | 31 +++- libspi/accessibleeventlistener.h | 31 ++-- libspi/application.c | 2 + libspi/desktop.c | 11 +- libspi/deviceeventcontroller.c | 39 +++-- libspi/eventlistener.c | 31 +++- libspi/eventlistener.h | 31 ++-- libspi/hypertext.c | 13 +- libspi/hypertext.h | 4 +- libspi/keystrokelistener.c | 113 ++++++++++++--- libspi/keystrokelistener.h | 3 + libspi/registry.c | 54 ++++--- registryd/desktop.c | 11 +- registryd/deviceeventcontroller.c | 39 +++-- registryd/registry.c | 54 ++++--- test/keysynth-demo.c | 55 ++++---- test/simple-at.c | 73 +++++----- util/mag_client.h | 1 + util/mag_control.c | 1 + util/magnifier.c | 2 +- 50 files changed, 1126 insertions(+), 692 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7605b67..81b5432 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,158 @@ +2001-11-28 Bill Haneman + + Merged Michael's branch (see his ChangeLog entries below). + + * at-bridge/bridge.c: Explicitly hold a ref to the registry while + bridge is alive, release on exit. + + * cspi/spi-listener-impl.c (cspi_event_listener_add_callback): + Fix type check macro. + + * cspi/spi_event.c: + Added AccessibleKeystrokeListener_unref() method to reduce leakage. + + * cspi/spi_main.c: + Added is_gnome_app static, and method cspi_is_gnome_app(), + so we can call the appropriate shutdown routine at exit in SPI_exit. + + * cspi/spi_main.c (cspi_object_ref): + Duplicate the corba object passed in, since we're keeping it around. + + * cspi/SPI_exit.c, cspi_cleanup: + Moved the releasing of the live refs to its own function, so we + can put it in g_atexit (). Call the appropriate shutdown API + depending on whethe calling client is a gnome app or not + (bonobo_main_quit or CORBA_ORB_shutdown). + + * cspi/spi_registry.c (deregisterGlobalEventListenerAll): + Unref the listener when this method is called, after + deregistration. Updated the API docs to note this behavior. + + * libspi/accessible.c (impl_get_parent, impl_get_child_at_index): + Bugfixes: Ref the bonobo object when returning a parent or child + reference, or an AccessibleRelation. Generally made sure + BonoboObject refcount is incremented whenever we return an + Accessible. + + * libspi/accessibleeventlistener.c (spi_event_listener_class_init): + Fixed typo/bug in signal declaration. + + * libspi/accessibleeventlistener.h: + Fixed a type macro. + + * libspi/application.c (spi_application_new): + Fixed leak in initialization. + + * libspi/desktop.c: + Remembered to increment bonobo-object refcount when returning + children (applications) from desktop object. + Added (empty) finalize method. + + * libspi/deviceeventcontroller.c: + Hold a ref to listeners inside DEControllerKeyListeners. + Added dec_key_listener_free() method. Use prepend instead of + append in key_listener list. Fixed some refcount madness and + leaks in the listener registration/deregistration - deregistration + now calls dec_key_listener_free() on listeners, and on the + temporarily constructed dec_key_listener() used to perform the search/match. + + * libspi/hypertext.c (spi_hypertest_finalize): + Fixed 'double unref' of AtkObject held by parent SpiAccessibleText + class. Also fixed spi_hypertext_interface_new() and + SpiHypertextClass. Fixed a couple of paren-whitespace formatting bugs. + + * libspi/hypertext.h: + Removed pointless and duplicate AtkObject pointer from + SpiHypertextClass. + + * libspi/keystrokelistener.c: + Fixed incorrect type of keystroke_listener_parent_class, + renamed keystroke_listener_object_finalize to + spi_keystroke_listener_object_finalize. + Fixed typo in signal declaration + (spi_keystroke_listener_class_init). + + * libspi/registry.c: + Added funcsions spi_listener_struct_new() and + spi_listener_struct_free() to help with memory management issues. + We also now use these methods instead of gnew + poking stuff into + the struct, and to decrement listener counts/free the listeners + when deregistering them. + Fix more refcount bugs in getDesktop() and + getDeviceEventController(). + + * test/simple-at.c: + De-ref the desktop after enumerating the applications. Explicitly + decrement the refcounts on the created listeners on exit (using + _unref for keystroke listeners, and via the + deregisterGlobalEventListenerAll command for other event + listeners). + +2001-11-27 Michael Meeks + + * cspi/spi-listener.h: fixup enum. + +2001-11-27 Michael Meeks + + * cspi/spi-listener-impl.c (cspi_event_listener_new), + (cspi_keystroke_listener_new): Use the cspi variants. + +2001-11-26 Michael Meeks + + * test/keysynth-demo.c: fix 2 compile warnings, missing + type in decl. etc. + + * test/simple-at.c (report_focussed_accessible), + (report_focus_event, report_button_press), + (check_property_change, is_command_key), + (report_ordinary_key_event, report_command_key_event): upd. + + * util/mag_client.h: include pre-requisites. + + * libspi/accessibleeventlistener.c + (spi_event_listener_object_finalize): free any lingering + callbacks. + + * libspi/keystrokelistener.c + (keystroke_listener_object_finalize): ditto. + + * cspi/spi-listener-impl.[ch]: Add to implement cspi style + callbacks, with cspi types. + + * cspi/spi_event.c (createAccessibleEventListener): chain to + (AccessibleEventListener_addCallback): here. + (createAccessibleKeystrokeListener): chain to + (AccessibleKeystrokeListener_addCallback): here. + + * libspi/keystrokelistener.c + (spi_keystroke_listener_class_init): add signal. + (impl_key_event): emit the event. + (boolean_handled_accumulator): impl. + (marshal_BOOLEAN__POINTER): add, gack. + + * libspi/accessibleeventlistener.c + (spi_event_listener_class_init): add signal. + (impl_accessible_event_notify_event): emit the signal & + make the loop efficient. + (spi_event_listener_add_callback): prepend the callback. + + * libspi/accessibleeventlistener.h: add an 'event' signal, + decl type on callback. + + * libspi/keystrokelistener.h: ditto. + + * cspi/spi-listener.h: make methods typesafe and + make them use the new event typedefs. + + * test/simple-at.c (report_focussed_accessible): + include mag_client.h + Use *(void *)text_interface not the other thing. + + * configure.in: add gtk to registryd bits - since we use + gdk there ( why ? ) + + * util/magnifier.c: include libbonobo.h + 2001-11-25 Bill Haneman * test/keysynth-demo.c: diff --git a/at-bridge/bridge.c b/at-bridge/bridge.c index fe5ff16..e1ca88c 100644 --- a/at-bridge/bridge.c +++ b/at-bridge/bridge.c @@ -103,7 +103,6 @@ bridge_register_app (gpointer gp) ("Accessibility app error: exception during registry activation from id: %s\n"), CORBA_exception_id(&ev)); CORBA_exception_free(&ev); - exit(-1); } if (CORBA_Object_is_nil (oclient, &ev)) @@ -115,6 +114,8 @@ bridge_register_app (gpointer gp) fprintf(stderr, "About to register application\n"); + Accessibility_Registry_ref (registry, &ev); + bonobo_activate (); Accessibility_Registry_registerApplication (registry, @@ -164,6 +165,8 @@ static void bridge_exit_func() Accessibility_Registry_deregisterApplication (registry, CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev), &ev); + Accessibility_Registry_unref (registry, &ev); + fprintf (stderr, "bridge exit func complete.\n"); } diff --git a/atk-bridge/bridge.c b/atk-bridge/bridge.c index fe5ff16..e1ca88c 100644 --- a/atk-bridge/bridge.c +++ b/atk-bridge/bridge.c @@ -103,7 +103,6 @@ bridge_register_app (gpointer gp) ("Accessibility app error: exception during registry activation from id: %s\n"), CORBA_exception_id(&ev)); CORBA_exception_free(&ev); - exit(-1); } if (CORBA_Object_is_nil (oclient, &ev)) @@ -115,6 +114,8 @@ bridge_register_app (gpointer gp) fprintf(stderr, "About to register application\n"); + Accessibility_Registry_ref (registry, &ev); + bonobo_activate (); Accessibility_Registry_registerApplication (registry, @@ -164,6 +165,8 @@ static void bridge_exit_func() Accessibility_Registry_deregisterApplication (registry, CORBA_Object_duplicate (BONOBO_OBJREF (this_app), &ev), &ev); + Accessibility_Registry_unref (registry, &ev); + fprintf (stderr, "bridge exit func complete.\n"); } diff --git a/configure.in b/configure.in index 70424f7..501cd19 100644 --- a/configure.in +++ b/configure.in @@ -87,7 +87,7 @@ PKG_CHECK_MODULES(LIBSPI, bonobo-activation-2.0 >= 0.9.1 libbonobo-2.0 >= 1.97.0 AC_SUBST(LIBSPI_LIBS) AC_SUBST(LIBSPI_CFLAGS) -PKG_CHECK_MODULES(REGISTRYD, bonobo-activation-2.0 >= 0.9.1 libbonobo-2.0 >= 1.97.0 atk >= 0.2) +PKG_CHECK_MODULES(REGISTRYD, bonobo-activation-2.0 >= 0.9.1 libbonobo-2.0 >= 1.97.0 atk >= 0.2 gdk-2.0) AC_SUBST(REGISTRYD_LIBS) AC_SUBST(REGISTRYD_CFLAGS) diff --git a/cspi/Makefile.am b/cspi/Makefile.am index 2bdcc92..2d99a32 100644 --- a/cspi/Makefile.am +++ b/cspi/Makefile.am @@ -19,20 +19,22 @@ libcspi_HEADERS = \ spi-statetypes.h libcspi_la_SOURCES = \ - spi_main.c \ - spi_event.c \ - spi_registry.c \ - spi-util.c \ spi_accessible.c \ spi_action.c \ spi_application.c \ spi_component.c \ spi_editabletext.c \ + spi_event.c \ spi_hyperlink.c \ spi_hypertext.c \ spi_image.c \ + spi-listener-impl.h \ + spi-listener-impl.c \ + spi_main.c \ spi-private.h \ + spi_registry.c \ spi_selection.c \ spi_table.c \ spi_text.c \ + spi-util.c \ spi_value.c diff --git a/cspi/bonobo/cspi-bonobo-listener.c b/cspi/bonobo/cspi-bonobo-listener.c index ac1523c..e05e855 100644 --- a/cspi/bonobo/cspi-bonobo-listener.c +++ b/cspi/bonobo/cspi-bonobo-listener.c @@ -44,14 +44,14 @@ cspi_event_listener_class_init (CSpiEventListenerClass *klass) CSpiEventListener * cspi_event_listener_new (void) { - return g_object_new (spi_event_listener_get_type (), NULL); + return g_object_new (cspi_event_listener_get_type (), NULL); } void cspi_event_listener_add_callback (CSpiEventListener *listener, AccessibleEventListenerCB callback) { - g_return_if_fail (IS_CSPI_KEYSTROKE_LISTENER (listener)); + g_return_if_fail (IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER (listener)); listener->callbacks = g_slist_prepend (listener->callbacks, callback); } @@ -123,7 +123,7 @@ BONOBO_TYPE_FUNC (CSpiKeystrokeListener, CSpiKeystrokeListener * cspi_keystroke_listener_new (void) { - return g_object_new (spi_keystroke_listener_get_type (), NULL); + return g_object_new (cspi_keystroke_listener_get_type (), NULL); } void diff --git a/cspi/bonobo/cspi-bonobo-listener.h b/cspi/bonobo/cspi-bonobo-listener.h index 2dbf7c0..9316ac6 100644 --- a/cspi/bonobo/cspi-bonobo-listener.h +++ b/cspi/bonobo/cspi-bonobo-listener.h @@ -20,6 +20,7 @@ struct _CSpiEventListener { SpiEventListener parent; GSList *callbacks; }; + typedef SpiEventListenerClass CSpiEventListenerClass; GType cspi_event_listener_get_type (void); diff --git a/cspi/spi-impl.h b/cspi/spi-impl.h index 16b2eba..bc39c4a 100644 --- a/cspi/spi-impl.h +++ b/cspi/spi-impl.h @@ -1,39 +1,29 @@ /* - * Note: this header is a private implementation header, clients of - * the at-spi interfaces or the C bindings in libcspi should - * not depend on any of the information in this file directly, - * as it it not intended for use as a public interface. - * - * You have been warned ! + * A load of opaque handles that people can't poke at. */ - #ifndef _SPI_IMPL_H_ #define _SPI_IMPL_H_ -#include -#include -#include - -typedef unsigned int boolean; +typedef struct _Accessible Accessible; +typedef Accessible AccessibleAction; +typedef Accessible AccessibleApplication; +typedef Accessible AccessibleComponent; +typedef Accessible AccessibleEditableText; +typedef Accessible AccessibleHyperlink; +typedef Accessible AccessibleHypertext; +typedef Accessible AccessibleImage; +typedef Accessible AccessibleRelation; +typedef Accessible AccessibleSelection; +typedef Accessible AccessibleStateSet; +typedef Accessible AccessibleTable; +typedef Accessible AccessibleText; +typedef Accessible AccessibleValue; +typedef Accessible AccessibilityRegistry; +typedef Accessible GenericInterface; -typedef CORBA_Object Accessible; -typedef CORBA_Object AccessibleAction; -typedef CORBA_Object AccessibleApplication; -typedef CORBA_Object AccessibleComponent; -typedef CORBA_Object AccessibleEditableText; -typedef CORBA_Object AccessibleHyperlink; -typedef CORBA_Object AccessibleHypertext; -typedef CORBA_Object AccessibleImage; -typedef CORBA_Object AccessibleRelation; -typedef CORBA_Object AccessibleSelection; -typedef CORBA_Object AccessibleStateSet; -typedef CORBA_Object AccessibleTable; -typedef CORBA_Object AccessibleText; -typedef CORBA_Object AccessibleValue; -typedef CORBA_Object AccessibilityRegistry; -typedef CORBA_Object GenericInterface; +typedef struct _CSpiEventListener AccessibleEventListener; +typedef struct _CSpiKeystrokeListener AccessibleKeystrokeListener; -typedef SpiKeystrokeListener AccessibleKeystrokeListener; -typedef SpiEventListener AccessibleEventListener; +typedef unsigned int boolean; #endif diff --git a/cspi/spi-listener-impl.c b/cspi/spi-listener-impl.c index ac1523c..e05e855 100644 --- a/cspi/spi-listener-impl.c +++ b/cspi/spi-listener-impl.c @@ -44,14 +44,14 @@ cspi_event_listener_class_init (CSpiEventListenerClass *klass) CSpiEventListener * cspi_event_listener_new (void) { - return g_object_new (spi_event_listener_get_type (), NULL); + return g_object_new (cspi_event_listener_get_type (), NULL); } void cspi_event_listener_add_callback (CSpiEventListener *listener, AccessibleEventListenerCB callback) { - g_return_if_fail (IS_CSPI_KEYSTROKE_LISTENER (listener)); + g_return_if_fail (IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER (listener)); listener->callbacks = g_slist_prepend (listener->callbacks, callback); } @@ -123,7 +123,7 @@ BONOBO_TYPE_FUNC (CSpiKeystrokeListener, CSpiKeystrokeListener * cspi_keystroke_listener_new (void) { - return g_object_new (spi_keystroke_listener_get_type (), NULL); + return g_object_new (cspi_keystroke_listener_get_type (), NULL); } void diff --git a/cspi/spi-listener-impl.h b/cspi/spi-listener-impl.h index 2dbf7c0..9316ac6 100644 --- a/cspi/spi-listener-impl.h +++ b/cspi/spi-listener-impl.h @@ -20,6 +20,7 @@ struct _CSpiEventListener { SpiEventListener parent; GSList *callbacks; }; + typedef SpiEventListenerClass CSpiEventListenerClass; GType cspi_event_listener_get_type (void); diff --git a/cspi/spi-listener.h b/cspi/spi-listener.h index 99b1619..e69a2e7 100644 --- a/cspi/spi-listener.h +++ b/cspi/spi-listener.h @@ -1,21 +1,34 @@ #ifndef _SPI_LISTENER_H_ #define _SPI_LISTENER_H_ -#include -#include +#include G_BEGIN_DECLS /* - * * Structure used to encapsulate event information - * */ - -typedef Accessibility_Event AccessibleEvent; +typedef struct { + const char *type; + Accessible *source; + long detail1; + long detail2; +} AccessibleEvent; + +typedef enum { + SPI_KEY_PRESSED = 1<<0, + SPI_KEY_RELEASED = 1<<1 +} AccessibleKeyEventType; + +typedef struct { + long keyID; + short keycode; + long timestamp; + AccessibleKeyEventType type; + unsigned short modifiers; +} AccessibleKeystroke; /* - * * Function prototype typedefs for Event Listener Callbacks. * (see libspi/accessibleeventlistener.h for definition of SpiVoidEventListenerCB). * @@ -24,9 +37,8 @@ typedef Accessibility_Event AccessibleEvent; * * boolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystrokeEvent *Event); */ - -typedef VoidSpiEventListenerCB AccessibleEventListenerCB; -typedef BooleanKeystrokeListenerCB AccessibleKeystrokeListenerCB; +typedef void (*AccessibleEventListenerCB) (AccessibleEvent *event); +typedef boolean (*AccessibleKeystrokeListenerCB) (AccessibleKeystroke *stroke); G_END_DECLS diff --git a/cspi/spi-private.h b/cspi/spi-private.h index 64eba34..8bb4c16 100644 --- a/cspi/spi-private.h +++ b/cspi/spi-private.h @@ -1,20 +1,32 @@ -#ifndef __SPI_PRIVATE_H__ -#define __SPI_PRIVATE_H__ +#ifndef _SPI_PRIVATE_H_ +#define _SPI_PRIVATE_H_ -#include - -G_BEGIN_DECLS - -CORBA_Environment *spi_ev (void); -AccessibilityRegistry spi_registry (void); - -boolean spi_exception (void); +/* + * Private internal implementation details of at-spi. + */ -Accessible *spi_object_add (Accessible corba_object); - -int SPI_init (void); -void SPI_exit (void); - -G_END_DECLS - -#endif /* __SPI_PRIVATE_H__ */ +#include +#include +#include +#include "cspi/spi-listener.h" + +struct _Accessible { + CORBA_Object objref; + /* And some other bits */ + guint ref_count; +}; + +#define CSPI_OBJREF(a) (((Accessible *)(a))->objref) + +CORBA_Environment *cspi_ev (void); +boolean cspi_exception (void); +Accessibility_Registry cspi_registry (void); +Accessible *cspi_object_add (CORBA_Object corba_object); +void cspi_object_ref (Accessible *accessible); +void cspi_object_unref (Accessible *accessible); +boolean cspi_warn_ev (CORBA_Environment *ev, + const char *error_string); +void cspi_check_ev (CORBA_Environment *ev, + const char *error_string); + +#endif /* _SPI_PRIVATE_H_ */ diff --git a/cspi/spi-util.c b/cspi/spi-util.c index 6543055..5b4714a 100644 --- a/cspi/spi-util.c +++ b/cspi/spi-util.c @@ -1,5 +1,4 @@ #include -#include #include void @@ -9,7 +8,7 @@ spi_freeString (char *s) } boolean -spi_warn_ev (CORBA_Environment *ev, const char *error_string) +cspi_warn_ev (CORBA_Environment *ev, const char *error_string) { if (ev->_major != CORBA_NO_EXCEPTION) { @@ -33,7 +32,7 @@ spi_warn_ev (CORBA_Environment *ev, const char *error_string) } void -spi_check_ev (CORBA_Environment *ev, const char *error_string) +cspi_check_ev (CORBA_Environment *ev, const char *error_string) { if (ev->_major != CORBA_NO_EXCEPTION) { diff --git a/cspi/spi.h b/cspi/spi.h index 7d906d0..3e3e0bf 100644 --- a/cspi/spi.h +++ b/cspi/spi.h @@ -57,12 +57,6 @@ typedef enum { SPI_COORD_TYPE_WINDOW } AccessibleCoordType; -/* XXX: must be single bits since they are used as masks in keylistener API */ -typedef enum { - SPI_KEY_PRESSED = 1, - SPI_KEY_RELEASED = 2 -} AccessibleKeyEventType; - typedef enum { SPI_KEY_PRESS, SPI_KEY_RELEASE, @@ -79,14 +73,6 @@ typedef enum { typedef unsigned long AccessibleKeyEventMask; -typedef struct _AccessibleKeyStroke -{ - long keyID; - short keycode; - long timestamp; - AccessibleKeyEventType type; - unsigned short modifiers; -} AccessibleKeyStroke; /** * AccessibleKeySet: diff --git a/cspi/spi_accessible.c b/cspi/spi_accessible.c index 5afbd0f..9074be5 100644 --- a/cspi/spi_accessible.c +++ b/cspi/spi_accessible.c @@ -103,8 +103,7 @@ AccessibleRole_getName (AccessibleRole role) int Accessible_ref (Accessible *obj) { - Accessibility_Accessible_ref (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "ref"); + cspi_object_ref (obj); return 0; } @@ -121,8 +120,7 @@ Accessible_ref (Accessible *obj) int Accessible_unref (Accessible *obj) { - Accessibility_Accessible_unref (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "unref"); + cspi_object_unref (obj); return 0; } @@ -140,8 +138,8 @@ Accessible_getName (Accessible *obj) { char *retval = (char *) - Accessibility_Accessible__get_name (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "getName"); + Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ()); + cspi_check_ev (cspi_ev (), "getName"); return retval; } @@ -158,8 +156,8 @@ char * Accessible_getDescription (Accessible *obj) { char *retval = (char *) - Accessibility_Accessible__get_description (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "getDescription"); + Accessibility_Accessible__get_description (CSPI_OBJREF (obj), cspi_ev ()); + cspi_check_ev (cspi_ev (), "getDescription"); return retval; } @@ -177,8 +175,8 @@ Accessible * Accessible_getParent (Accessible *obj) { Accessible *retval = - spi_object_add (Accessibility_Accessible__get_parent (*obj, spi_ev ())); - spi_check_ev (spi_ev (), "getParent"); + cspi_object_add (Accessibility_Accessible__get_parent (CSPI_OBJREF (obj), cspi_ev ())); + cspi_check_ev (cspi_ev (), "getParent"); return retval; } @@ -195,8 +193,8 @@ Accessible_getParent (Accessible *obj) long Accessible_getChildCount (Accessible *obj) { - long retval = (long) Accessibility_Accessible__get_childCount (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "getChildCount"); + long retval = (long) Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj), cspi_ev ()); + cspi_check_ev (cspi_ev (), "getChildCount"); return retval; } @@ -215,8 +213,8 @@ Accessible * Accessible_getChildAtIndex (Accessible *obj, long int childIndex) { - Accessible *retval = spi_object_add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, spi_ev ())); - spi_check_ev (spi_ev (), "getChildAtIndex"); + Accessible *retval = cspi_object_add (Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj), childIndex, cspi_ev ())); + cspi_check_ev (cspi_ev (), "getChildAtIndex"); return retval; } @@ -234,8 +232,8 @@ Accessible_getChildAtIndex (Accessible *obj, long Accessible_getIndexInParent (Accessible *obj) { - long retval = (long) Accessibility_Accessible_getIndexInParent (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "getIndexInParent"); + long retval = (long) Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ()); + cspi_check_ev (cspi_ev (), "getIndexInParent"); return retval; } @@ -256,7 +254,7 @@ Accessible_getRelationSet (Accessible *obj) int n_relations; int i; Accessibility_RelationSet *relation_set = - Accessibility_Accessible_getRelationSet (*obj, spi_ev ()); + Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ()); /* this looks hack-ish, but it's based on the CORBA C bindings spec */ n_relations = relation_set->_length; @@ -264,7 +262,7 @@ Accessible_getRelationSet (Accessible *obj) for (i=0; i_buffer[i]); + relations[i] = cspi_object_add (relation_set->_buffer[i]); } relations[i] = CORBA_OBJECT_NIL; @@ -284,8 +282,8 @@ char * Accessible_getRole (Accessible *obj) { char *retval = AccessibleRole_getName ( - Accessibility_Accessible_getRole (*obj, spi_ev ())); - spi_check_ev (spi_ev (), "getRole"); + Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ())); + cspi_check_ev (cspi_ev (), "getRole"); return retval; } @@ -305,6 +303,36 @@ Accessible_getStateSet (Accessible *obj) /* Interface query methods */ +static boolean +cspi_accessible_is_a (Accessible *obj, + const char *interface_name) +{ + boolean retval; + Bonobo_Unknown unknown; + + unknown = Bonobo_Unknown_queryInterface (CSPI_OBJREF (obj), + interface_name, cspi_ev ()); + + if (BONOBO_EX (cspi_ev ())) + { + g_error ("Exception '%s' checking if is '%s'", + bonobo_exception_get_text (cspi_ev ()), + interface_name); + } + + if (unknown != CORBA_OBJECT_NIL) + { + retval = TRUE; + bonobo_object_release_unref (unknown, NULL); + } + else + { + retval= FALSE; + } + + return retval; +} + /** * Accessible_isAction: * @obj: a pointer to the #Accessible instance to query. @@ -317,13 +345,8 @@ Accessible_getStateSet (Accessible *obj) boolean Accessible_isAction (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Action:1.0", - spi_ev ()); - spi_warn_ev (spi_ev (), "isAction"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Action:1.0"); } /** @@ -338,13 +361,8 @@ Accessible_isAction (Accessible *obj) boolean Accessible_isComponent (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Component:1.0", - spi_ev ()); - spi_warn_ev (spi_ev (), "isComponent"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Component:1.0"); } /** @@ -359,13 +377,8 @@ Accessible_isComponent (Accessible *obj) boolean Accessible_isEditableText (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/EditableText:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "isEditableText"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/EditableText:1.0"); } /** @@ -380,14 +393,8 @@ Accessible_isEditableText (Accessible *obj) boolean Accessible_isHypertext (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Hypertext:1.0", - spi_ev ()); - - spi_check_ev (spi_ev (), "isHypertext"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Hypertext:1.0"); } /** @@ -402,13 +409,8 @@ Accessible_isHypertext (Accessible *obj) boolean Accessible_isImage (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Image:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "isImage"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Image:1.0"); } /** @@ -423,14 +425,8 @@ Accessible_isImage (Accessible *obj) boolean Accessible_isSelection (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Selection:1.0", - spi_ev ()); - spi_warn_ev (spi_ev (), "isSelection"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; - + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Selection:1.0"); } /** @@ -445,14 +441,8 @@ Accessible_isSelection (Accessible *obj) boolean Accessible_isTable (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Table:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "isTable"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; - + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Table:1.0"); } /** @@ -467,13 +457,8 @@ Accessible_isTable (Accessible *obj) boolean Accessible_isText (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Text:1.0", - spi_ev ()); - spi_warn_ev (spi_ev (), "isText"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Text:1.0"); } /** @@ -488,13 +473,8 @@ Accessible_isText (Accessible *obj) boolean Accessible_isValue (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Value:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "isValue"); - - return (CORBA_Object_is_nil (iface, spi_ev ())) ? FALSE : TRUE; + return cspi_accessible_is_a (obj, + "IDL:Accessibility/Value:1.0"); } /** @@ -509,13 +489,8 @@ Accessible_isValue (Accessible *obj) AccessibleAction * Accessible_getAction (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Action:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getAction"); - - return (AccessibleAction *) spi_object_add (iface); + return (AccessibleAction *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Action:1.0"); } /** @@ -530,13 +505,8 @@ Accessible_getAction (Accessible *obj) AccessibleComponent * Accessible_getComponent (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Component:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getComponent"); - - return (AccessibleComponent *) spi_object_add (iface); + return (AccessibleComponent *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Component:1.0"); } /** @@ -551,13 +521,8 @@ Accessible_getComponent (Accessible *obj) AccessibleEditableText * Accessible_getEditableText (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/EditableText:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getEditableText"); - - return (AccessibleEditableText *) spi_object_add (iface); + return (AccessibleEditableText *) Accessible_queryInterface ( + obj, "IDL:Accessibility/EditableText:1.0"); } @@ -574,13 +539,8 @@ Accessible_getEditableText (Accessible *obj) AccessibleHypertext * Accessible_getHypertext (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Hypertext:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getHypertext"); - - return (AccessibleHypertext *) spi_object_add (iface); + return (AccessibleHypertext *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Hypertext:1.0"); } @@ -597,13 +557,8 @@ Accessible_getHypertext (Accessible *obj) AccessibleImage * Accessible_getImage (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Image:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getImage"); - - return (AccessibleImage *) spi_object_add (iface); + return (AccessibleImage *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Image:1.0"); } @@ -620,13 +575,8 @@ Accessible_getImage (Accessible *obj) AccessibleSelection * Accessible_getSelection (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Selection:1.0", - spi_ev ()); - spi_warn_ev (spi_ev (), "getSelection"); - - return (AccessibleSelection *) spi_object_add (iface); + return (AccessibleSelection *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Selection:1.0"); } @@ -643,13 +593,8 @@ Accessible_getSelection (Accessible *obj) AccessibleTable * Accessible_getTable (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Table:1.0", - spi_ev ()); - spi_check_ev (spi_ev (), "getTable"); - - return (AccessibleTable *) spi_object_add (iface); + return (AccessibleTable *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Table:1.0"); } /** @@ -664,14 +609,8 @@ Accessible_getTable (Accessible *obj) AccessibleText * Accessible_getText (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Text:1.0", - spi_ev ()); - - spi_check_ev (spi_ev (), "getText"); - - return (AccessibleText *) spi_object_add (iface); + return (AccessibleText *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Text:1.0"); } @@ -688,11 +627,8 @@ Accessible_getText (Accessible *obj) AccessibleValue * Accessible_getValue (Accessible *obj) { - Bonobo_Unknown iface = - Accessibility_Accessible_queryInterface (*obj, - "IDL:Accessibility/Value:1.0", - spi_ev ()); - return (AccessibleValue *) spi_object_add (iface); + return (AccessibleValue *) Accessible_queryInterface ( + obj, "IDL:Accessibility/Value:1.0"); } @@ -711,11 +647,22 @@ Accessible_getValue (Accessible *obj) GenericInterface * Accessible_queryInterface (Accessible *obj, char *interface_name) { - GenericInterface iface; - iface = Accessibility_Accessible_queryInterface (*obj, - interface_name, - spi_ev ()); - return spi_object_add (iface); + Bonobo_Unknown iface; + + iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj), + interface_name, + cspi_ev ()); + + /* + * FIXME: we need to be fairly sure that references are going + * to mach up if we are going to expose QueryInterface, ie. we + * can't allow people to do: + * b = a.qi ("b"); b.unref, b.unref to release a's reference. + * this should be no real problem though for this level of API + * user. + */ + + return cspi_object_add (iface); } @@ -731,8 +678,7 @@ Accessible_queryInterface (Accessible *obj, char *interface_name) int AccessibleRelation_ref (AccessibleRelation *obj) { - Accessibility_Relation_ref (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "ref"); + cspi_object_ref (obj); return 0; } @@ -748,8 +694,7 @@ AccessibleRelation_ref (AccessibleRelation *obj) int AccessibleRelation_unref (AccessibleRelation *obj) { - Accessibility_Relation_unref (*obj, spi_ev ()); - spi_check_ev (spi_ev (), "unref"); + cspi_object_unref (obj); return 0; } @@ -817,8 +762,7 @@ AccessibleRelation_getTarget (AccessibleRelation *obj, int i) int AccessibleStateSet_ref (AccessibleStateSet *obj) { -/* Accessibility_StateSet_ref (*obj, spi_ev ()); */ - spi_check_ev (spi_ev (), "ref"); + cspi_object_ref (obj); return 0; } @@ -834,8 +778,7 @@ AccessibleStateSet_ref (AccessibleStateSet *obj) int AccessibleStateSet_unref (AccessibleStateSet *obj) { -/* Accessibility_StateSet_unref (*obj, spi_ev ()); */ - spi_check_ev (spi_ev (), "unref"); + cspi_object_unref (obj); return 0; } @@ -857,8 +800,8 @@ boolean AccessibleStateSet_contains (AccessibleStateSet *obj, AccessibleState state) { - CORBA_boolean retval = Accessibility_StateSet_contains (*obj, state, spi_ev ()); - spi_check_ev (spi_ev (), "contains"); + CORBA_boolean retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj), state, cspi_ev ()); + cspi_check_ev (cspi_ev (), "contains"); return (boolean) retval; } @@ -875,8 +818,8 @@ void AccessibleStateSet_add (AccessibleStateSet *obj, AccessibleState state) { - Accessibility_StateSet_add (*obj, state, spi_ev ()); - spi_check_ev (spi_ev (), "contains"); + Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ()); + cspi_check_ev (cspi_ev (), "contains"); } @@ -893,8 +836,8 @@ void AccessibleStateSet_remove (AccessibleStateSet *obj, AccessibleState state) { - Accessibility_StateSet_remove (*obj, state, spi_ev ()); - spi_check_ev (spi_ev (), "contains"); + Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ()); + cspi_check_ev (cspi_ev (), "contains"); } /** @@ -916,7 +859,7 @@ boolean AccessibleStateSet_equals (AccessibleStateSet *obj, AccessibleStateSet *obj2) { - return Accessibility_StateSet_equals (*obj, *obj2, spi_ev ()); + return Accessibility_StateSet_equals (CSPI_OBJREF (obj), CSPI_OBJREF (obj2), cspi_ev ()); } /** @@ -955,7 +898,7 @@ boolean AccessibleStateSet_isEmpty (AccessibleStateSet *obj) { return TRUE; - /* return Accessibility_StateSet_isEmpty (*obj, spi_ev ());*/ + /* return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/ } diff --git a/cspi/spi_action.c b/cspi/spi_action.c index 70f5764..1d4d382 100644 --- a/cspi/spi_action.c +++ b/cspi/spi_action.c @@ -10,10 +10,9 @@ * **/ int -AccessibleAction_ref ( - AccessibleAction *obj) +AccessibleAction_ref (AccessibleAction *obj) { - Accessibility_Action_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -29,7 +28,7 @@ AccessibleAction_ref ( int AccessibleAction_unref (AccessibleAction *obj) { - Accessibility_Action_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -48,7 +47,7 @@ long AccessibleAction_getNActions (AccessibleAction *obj) { return (long) - Accessibility_Action__get_nActions (*obj, spi_ev ()); + Accessibility_Action__get_nActions (CSPI_OBJREF (obj), cspi_ev ()); } @@ -68,9 +67,9 @@ AccessibleAction_getDescription (AccessibleAction *obj, long int i) { return (char *) - Accessibility_Action_getDescription (*obj, + Accessibility_Action_getDescription (CSPI_OBJREF (obj), (CORBA_long) i, - spi_ev ()); + cspi_ev ()); } /** @@ -90,9 +89,9 @@ AccessibleAction_getKeyBinding (AccessibleAction *obj, long int i) { return (char *) - Accessibility_Action_getKeyBinding (*obj, + Accessibility_Action_getKeyBinding (CSPI_OBJREF (obj), (CORBA_long) i, - spi_ev ()); + cspi_ev ()); } @@ -113,9 +112,9 @@ AccessibleAction_getName (AccessibleAction *obj, long int i) { return (char *) - Accessibility_Action_getName (*obj, + Accessibility_Action_getName (CSPI_OBJREF (obj), (CORBA_long) i, - spi_ev ()); + cspi_ev ()); } @@ -134,9 +133,9 @@ AccessibleAction_doAction (AccessibleAction *obj, long int i) { return (boolean) - Accessibility_Action_doAction (*obj, + Accessibility_Action_doAction (CSPI_OBJREF (obj), (CORBA_long) i, - spi_ev ()); + cspi_ev ()); } diff --git a/cspi/spi_application.c b/cspi/spi_application.c index 0e5a760..052f7a1 100644 --- a/cspi/spi_application.c +++ b/cspi/spi_application.c @@ -18,7 +18,7 @@ int AccessibleApplication_ref (AccessibleApplication *obj) { - Accessibility_Application_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -34,7 +34,7 @@ AccessibleApplication_ref (AccessibleApplication *obj) int AccessibleApplication_unref (AccessibleApplication *obj) { - Accessibility_Application_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -51,7 +51,7 @@ AccessibleApplication_unref (AccessibleApplication *obj) char * AccessibleApplication_getToolkitName (AccessibleApplication *obj) { - return Accessibility_Application__get_toolkitName (*obj, spi_ev ()); + return Accessibility_Application__get_toolkitName (CSPI_OBJREF (obj), cspi_ev ()); } /** @@ -68,7 +68,7 @@ AccessibleApplication_getToolkitName (AccessibleApplication *obj) char * AccessibleApplication_getVersion (AccessibleApplication *obj) { - return Accessibility_Application__get_version (*obj, spi_ev ()); + return Accessibility_Application__get_version (CSPI_OBJREF (obj), cspi_ev ()); } /** @@ -85,7 +85,7 @@ AccessibleApplication_getVersion (AccessibleApplication *obj) long AccessibleApplication_getID (AccessibleApplication *obj) { - return Accessibility_Application__get_id (*obj, spi_ev ()); + return Accessibility_Application__get_id (CSPI_OBJREF (obj), cspi_ev ()); } /** diff --git a/cspi/spi_component.c b/cspi/spi_component.c index ff4b6d8..0ba17b6 100644 --- a/cspi/spi_component.c +++ b/cspi/spi_component.c @@ -18,7 +18,7 @@ int AccessibleComponent_ref (AccessibleComponent *obj) { - Accessibility_Component_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -34,7 +34,7 @@ AccessibleComponent_ref (AccessibleComponent *obj) int AccessibleComponent_unref (AccessibleComponent *obj) { - Accessibility_Component_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -44,7 +44,7 @@ AccessibleComponent_unref (AccessibleComponent *obj) * @x: a #long specifying the x coordinate in question. * @y: a #long specifying the y coordinate in question. * @ctype: the desired coordinate system of the point (@x, @y) - * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * * Query whether a given #AccessibleComponent contains a particular point. * @@ -57,11 +57,11 @@ AccessibleComponent_contains (AccessibleComponent *obj, long int y, AccessibleCoordType ctype) { - return Accessibility_Component_contains (*obj, + return Accessibility_Component_contains (CSPI_OBJREF (obj), (CORBA_long) x, (CORBA_long) y, ctype, - spi_ev ()); + cspi_ev ()); } /** @@ -70,7 +70,7 @@ AccessibleComponent_contains (AccessibleComponent *obj, * @x: a #long specifying the x coordinate of the point in question. * @y: a #long specifying the y coordinate of the point in question. * @ctype: the coordinate system of the point (@x, @y) - * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * * Get the accessible child at a given coordinate within an #AccessibleComponent. * @@ -83,13 +83,14 @@ AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj, long int y, AccessibleCoordType ctype) { - Accessible child; - child = Accessibility_Component_getAccessibleAtPoint(*obj, + Accessibility_Accessible child; + + child = Accessibility_Component_getAccessibleAtPoint(CSPI_OBJREF (obj), (CORBA_long) x, (CORBA_long) y, ctype, - spi_ev ()); - return spi_object_add (child); + cspi_ev ()); + return cspi_object_add (child); } /** @@ -100,7 +101,7 @@ AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj, * @width: a pointer to a #long into which the x extents (width) will be returned. * @height: a pointer to a #long into which the y extents (height) will be returned. * @ctype: the desired coordinate system into which to return the results, - * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * * Get the bounding box of the specified #AccessibleComponent. * @@ -114,14 +115,14 @@ AccessibleComponent_getExtents (AccessibleComponent *obj, AccessibleCoordType ctype) { CORBA_long cx, cy, cw, ch; - Accessibility_Component_getExtents (*obj, + Accessibility_Component_getExtents (CSPI_OBJREF (obj), &cx, &cy, &cw, &ch, ctype, - spi_ev ()); - spi_warn_ev (spi_ev (), "AccessibleComponent_getExtents"); + cspi_ev ()); + cspi_warn_ev (cspi_ev (), "AccessibleComponent_getExtents"); *x = (long) cx; *y = (long) cy; *width = (long) cw; @@ -134,7 +135,7 @@ AccessibleComponent_getExtents (AccessibleComponent *obj, * @x: a pointer to a #long into which the minimum x coordinate will be returned. * @y: a pointer to a #long into which the minimum y coordinate will be returned. * @ctype: the desired coordinate system into which to return the results, - * (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * * Get the minimum x and y coordinates of the specified #AccessibleComponent. * @@ -145,11 +146,11 @@ AccessibleComponent_getPosition (AccessibleComponent *obj, long int *y, AccessibleCoordType ctype) { - Accessibility_Component_getPosition (*obj, + Accessibility_Component_getPosition (CSPI_OBJREF (obj), (CORBA_long *) x, (CORBA_long *) y, ctype, - spi_ev ()); + cspi_ev ()); } /** @@ -166,10 +167,10 @@ AccessibleComponent_getSize (AccessibleComponent *obj, long int *width, long int *height) { - Accessibility_Component_getSize (*obj, + Accessibility_Component_getSize (CSPI_OBJREF (obj), (CORBA_long *) width, (CORBA_long *) height, - spi_ev ()); + cspi_ev ()); } /** diff --git a/cspi/spi_editabletext.c b/cspi/spi_editabletext.c index 56dae87..9ef0a5a 100644 --- a/cspi/spi_editabletext.c +++ b/cspi/spi_editabletext.c @@ -14,7 +14,7 @@ int AccessibleEditableText_ref (AccessibleEditableText *obj) { - Accessibility_EditableText_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -34,7 +34,7 @@ AccessibleEditableText_ref (AccessibleEditableText *obj) int AccessibleEditableText_unref (AccessibleEditableText *obj) { - Accessibility_EditableText_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -61,10 +61,10 @@ AccessibleEditableText_setAttributes (AccessibleEditableText *obj, long int endPos) { return (boolean) - Accessibility_EditableText_setAttributes (*obj, + Accessibility_EditableText_setAttributes (CSPI_OBJREF (obj), (CORBA_char *) attributes, (CORBA_long) startPos, - (CORBA_long) endPos, spi_ev ()); + (CORBA_long) endPos, cspi_ev ()); } @@ -84,8 +84,8 @@ boolean AccessibleEditableText_setTextContents (AccessibleEditableText *obj, const char *newContents) { - Accessibility_EditableText_setTextContents (*obj, - (CORBA_char *) newContents, spi_ev ()); + Accessibility_EditableText_setTextContents (CSPI_OBJREF (obj), + (CORBA_char *) newContents, cspi_ev ()); return TRUE; /* TODO: make bonobo method return a boolean */ } @@ -113,9 +113,9 @@ AccessibleEditableText_insertText (AccessibleEditableText *obj, char *text, long int length) { - Accessibility_EditableText_insertText (*obj, + Accessibility_EditableText_insertText (CSPI_OBJREF (obj), (CORBA_long) position, (CORBA_char *) text, - (CORBA_long) length, spi_ev ()); + (CORBA_long) length, cspi_ev ()); return TRUE; } @@ -141,8 +141,8 @@ AccessibleEditableText_copyText (AccessibleText *obj, long int startPos, long int endPos) { - Accessibility_EditableText_copyText (*obj, - (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ()); + Accessibility_EditableText_copyText (CSPI_OBJREF (obj), + (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ()); return TRUE; } @@ -168,8 +168,8 @@ AccessibleEditableText_cutText (AccessibleEditableText *obj, long int startPos, long int endPos) { - Accessibility_EditableText_cutText (*obj, - (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ()); + Accessibility_EditableText_cutText (CSPI_OBJREF (obj), + (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ()); return TRUE; } @@ -196,8 +196,8 @@ AccessibleEditableText_deleteText (AccessibleEditableText *obj, long startPos, long endPos) { - Accessibility_EditableText_deleteText (*obj, - (CORBA_long) startPos, (CORBA_long) endPos, spi_ev ()); + Accessibility_EditableText_deleteText (CSPI_OBJREF (obj), + (CORBA_long) startPos, (CORBA_long) endPos, cspi_ev ()); return TRUE; } @@ -221,8 +221,8 @@ boolean AccessibleEditableText_pasteText (AccessibleEditableText *obj, long int position) { - Accessibility_EditableText_pasteText (*obj, - (CORBA_long) position, spi_ev ()); + Accessibility_EditableText_pasteText (CSPI_OBJREF (obj), + (CORBA_long) position, cspi_ev ()); return TRUE; } diff --git a/cspi/spi_event.c b/cspi/spi_event.c index 4a3149e..808b4dd 100644 --- a/cspi/spi_event.c +++ b/cspi/spi_event.c @@ -21,6 +21,7 @@ */ #include +#include /** * createAccessibleEventListener: @@ -34,10 +35,10 @@ AccessibleEventListener * createAccessibleEventListener (AccessibleEventListenerCB callback) { - AccessibleEventListener *listener = spi_event_listener_new (); + AccessibleEventListener *listener = cspi_event_listener_new (); if (callback) { - spi_event_listener_add_callback (listener, callback); + AccessibleEventListener_addCallback (listener, callback); } return listener; } @@ -59,9 +60,9 @@ createAccessibleEventListener (AccessibleEventListenerCB callback) **/ boolean AccessibleEventListener_addCallback (AccessibleEventListener *listener, - AccessibleEventListenerCB callback) + AccessibleEventListenerCB callback) { - spi_event_listener_add_callback (listener, callback); + cspi_event_listener_add_callback (listener, callback); return TRUE; } @@ -76,10 +77,10 @@ AccessibleEventListener_addCallback (AccessibleEventListener *listener, * **/ boolean -AccessibleEventListener_removeCallback (AccessibleEventListener *listener, +AccessibleEventListener_removeCallback (AccessibleEventListener *listener, AccessibleEventListenerCB callback) { -/* spi_event_listener_remove_callback (listener, callback); */ + cspi_event_listener_remove_callback (listener, callback); return TRUE; } @@ -95,10 +96,10 @@ AccessibleEventListener_removeCallback (AccessibleEventListener *listener, AccessibleKeystrokeListener * createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback) { - SpiKeystrokeListener *listener = spi_keystroke_listener_new (); + CSpiKeystrokeListener *listener = cspi_keystroke_listener_new (); if (callback) { - spi_keystroke_listener_add_callback (listener, callback); + AccessibleKeystrokeListener_addCallback (listener, callback); } return (AccessibleKeystrokeListener *)listener; } @@ -117,7 +118,7 @@ boolean AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener, AccessibleKeystrokeListenerCB callback) { - spi_keystroke_listener_add_callback (listener, callback); + cspi_keystroke_listener_add_callback (listener, callback); return TRUE; } @@ -135,7 +136,19 @@ boolean AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener, AccessibleKeystrokeListenerCB callback) { - spi_keystroke_listener_remove_callback (listener, callback); + cspi_keystroke_listener_remove_callback (listener, callback); return TRUE; } + +/** + * AccessibleKeystrokeListener_unref: + * @listener: a pointer to the #AccessibleKeystrokeListener being operated on. + * + * Decrements an #AccessibleKeystrokeListener's reference count. + **/ +void AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener) +{ + /* Would prefer this not to be bonobo api */ + bonobo_object_unref (BONOBO_OBJECT (listener)); +} diff --git a/cspi/spi_hyperlink.c b/cspi/spi_hyperlink.c index 458b735..34c5480 100644 --- a/cspi/spi_hyperlink.c +++ b/cspi/spi_hyperlink.c @@ -12,7 +12,7 @@ int AccessibleHyperlink_ref (AccessibleHyperlink *obj) { - Accessibility_Hyperlink_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -30,7 +30,7 @@ AccessibleHyperlink_ref (AccessibleHyperlink *obj) int AccessibleHyperlink_unref (AccessibleHyperlink *obj) { - Accessibility_Hyperlink_unref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -51,7 +51,7 @@ long AccessibleHyperlink_getNAnchors (AccessibleHyperlink *obj) { return (long) - Accessibility_Hyperlink__get_nAnchors (*obj, spi_ev ()); + Accessibility_Hyperlink__get_nAnchors (CSPI_OBJREF (obj), cspi_ev ()); } @@ -70,8 +70,8 @@ AccessibleHyperlink_getURI (AccessibleHyperlink *obj, long int i) { return (char *) - Accessibility_Hyperlink_getURI (*obj, - (CORBA_long) i, spi_ev ()); + Accessibility_Hyperlink_getURI (CSPI_OBJREF (obj), + (CORBA_long) i, cspi_ev ()); } /** @@ -89,9 +89,9 @@ Accessible* AccessibleHyperlink_getObject (AccessibleHyperlink *obj, long int i) { - return spi_object_add ( - Accessibility_Hyperlink_getObject (*obj, - (CORBA_long) i, spi_ev ())); + return cspi_object_add ( + Accessibility_Hyperlink_getObject (CSPI_OBJREF (obj), + (CORBA_long) i, cspi_ev ())); } /** @@ -113,9 +113,9 @@ AccessibleHyperlink_getIndexRange (AccessibleHyperlink *obj, long int *endIndex) { *startIndex = (long) - Accessibility_Hyperlink__get_startIndex (*obj, spi_ev ()); + Accessibility_Hyperlink__get_startIndex (CSPI_OBJREF (obj), cspi_ev ()); *endIndex = (long) - Accessibility_Hyperlink__get_endIndex (*obj, spi_ev ()); + Accessibility_Hyperlink__get_endIndex (CSPI_OBJREF (obj), cspi_ev ()); } @@ -135,7 +135,7 @@ boolean AccessibleHyperlink_isValid (AccessibleHyperlink *obj) { return (boolean) - Accessibility_Hyperlink_isValid (*obj, spi_ev ()); + Accessibility_Hyperlink_isValid (CSPI_OBJREF (obj), cspi_ev ()); } diff --git a/cspi/spi_hypertext.c b/cspi/spi_hypertext.c index d5ea317..2c8128c 100644 --- a/cspi/spi_hypertext.c +++ b/cspi/spi_hypertext.c @@ -14,7 +14,7 @@ int AccessibleHypertext_ref (AccessibleHypertext *obj) { - Accessibility_Hypertext_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -33,7 +33,7 @@ AccessibleHypertext_ref (AccessibleHypertext *obj) int AccessibleHypertext_unref (AccessibleHypertext *obj) { - Accessibility_Hypertext_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -57,7 +57,7 @@ long AccessibleHypertext_getNLinks (AccessibleHypertext *obj) { return (long) - Accessibility_Hypertext_getNLinks (*obj, spi_ev ()); + Accessibility_Hypertext_getNLinks (CSPI_OBJREF (obj), cspi_ev ()); } @@ -76,8 +76,8 @@ AccessibleHypertext_getLink (AccessibleHypertext *obj, long int linkIndex) { return (AccessibleHyperlink *) - Accessibility_Hypertext_getLink (*obj, - (CORBA_long) linkIndex, spi_ev ()); + Accessibility_Hypertext_getLink (CSPI_OBJREF (obj), + (CORBA_long) linkIndex, cspi_ev ()); } @@ -99,8 +99,8 @@ AccessibleHypertext_getLinkIndex (AccessibleHypertext *obj, long int characterOffset) { return (long) - Accessibility_Hypertext_getLinkIndex (*obj, - (CORBA_long) characterOffset, spi_ev ()); + Accessibility_Hypertext_getLinkIndex (CSPI_OBJREF (obj), + (CORBA_long) characterOffset, cspi_ev ()); } diff --git a/cspi/spi_image.c b/cspi/spi_image.c index 8c970e1..2e0b5f3 100644 --- a/cspi/spi_image.c +++ b/cspi/spi_image.c @@ -12,7 +12,7 @@ int AccessibleImage_ref (AccessibleImage *obj) { - Accessibility_Image_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -30,7 +30,7 @@ AccessibleImage_ref (AccessibleImage *obj) int AccessibleImage_unref (AccessibleImage *obj) { - Accessibility_Image_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -48,7 +48,7 @@ char * AccessibleImage_getImageDescription (AccessibleImage *obj) { return (char *) - Accessibility_Image__get_imageDescription (*obj, spi_ev ()); + Accessibility_Image__get_imageDescription (CSPI_OBJREF (obj), cspi_ev ()); } @@ -67,8 +67,8 @@ AccessibleImage_getImageSize (AccessibleImage *obj, long int *width, long int *height) { - Accessibility_Image_getImageSize (*obj, - (CORBA_long *) width, (CORBA_long *) height, spi_ev ()); + Accessibility_Image_getImageSize (CSPI_OBJREF (obj), + (CORBA_long *) width, (CORBA_long *) height, cspi_ev ()); } @@ -91,7 +91,7 @@ AccessibleImage_getImagePosition (AccessibleImage *obj, long *y, AccessibleCoordType ctype) { - Accessibility_Image_getImagePosition (*obj, + Accessibility_Image_getImagePosition (CSPI_OBJREF (obj), (CORBA_long *) x, (CORBA_long *) y, (CORBA_short) ctype, - spi_ev ()); + cspi_ev ()); } diff --git a/cspi/spi_main.c b/cspi/spi_main.c index 6d11747..cfbcfbf 100644 --- a/cspi/spi_main.c +++ b/cspi/spi_main.c @@ -3,29 +3,36 @@ * Basic SPI initialization and event loop function prototypes * */ +#include #include -#include #include static CORBA_Environment ev = { 0 }; -static AccessibilityRegistry registry = CORBA_OBJECT_NIL; +static Accessibility_Registry registry = CORBA_OBJECT_NIL; +static boolean is_gnome_app = FALSE; +static GSList *live_refs = NULL; CORBA_Environment * -spi_ev (void) +cspi_ev (void) { /* This method is an ugly hack */ return &ev; } -AccessibilityRegistry -spi_registry (void) +Accessibility_Registry +cspi_registry (void) { - /* This method is an ugly hack */ return registry; } boolean -spi_exception (void) +cspi_is_gnome_app (void) +{ + return is_gnome_app; +} + +boolean +cspi_exception (void) { boolean retval; @@ -43,18 +50,79 @@ spi_exception (void) } Accessible * -spi_object_add (Accessible corba_object) +cspi_object_add (CORBA_Object corba_object) { - /* TODO: keep list of live object refs */ - Accessible *oref = NULL; + Accessible *ref; if (corba_object != CORBA_OBJECT_NIL) { - oref = g_malloc (sizeof (Accessible)); - *oref = corba_object; + ref = g_new (Accessible, 1); + + ref->objref = CORBA_Object_duplicate (corba_object, cspi_ev()); + ref->ref_count = 1; + + live_refs = g_slist_prepend (live_refs, ref); + } + else + { + ref = NULL; + } + + return ref; +} + +void +cspi_object_ref (Accessible *accessible) +{ + g_return_if_fail (accessible != NULL); + + accessible->ref_count++; +} + +void +cspi_object_unref (Accessible *accessible) +{ + g_return_if_fail (accessible != NULL); + + if (--accessible->ref_count == 0) + { + live_refs = g_slist_remove (live_refs, accessible); + + bonobo_object_release_unref (accessible->objref, cspi_ev ()); + + cspi_check_ev (cspi_ev (), "unref"); + + memset (accessible, 0xaa, sizeof (Accessible)); + + g_free (accessible); + } +} + +static void +cspi_cleanup (void) +{ + GSList *l, *refs; + + refs = live_refs; + live_refs = NULL; + + for (l = refs; l; l = l->next) + { + Accessible *a = l->data; + + g_print ("releasing %p\n", l->data); + bonobo_object_release_unref (a->objref, NULL); + + g_free (a); + } + + g_slist_free (refs); + + if (registry != CORBA_OBJECT_NIL) + { + bonobo_object_release_unref (registry, NULL); + registry = CORBA_OBJECT_NIL; } - - return oref; } /** @@ -69,7 +137,6 @@ SPI_init (void) { int argc = 0; char *obj_id; - CORBA_Object oclient; static gboolean inited = FALSE; if (inited) @@ -88,24 +155,24 @@ SPI_init (void) obj_id = "OAFIID:Accessibility_Registry:proto0.1"; - oclient = bonobo_activation_activate_from_id ( - obj_id, 0, NULL, spi_ev ()); + registry = bonobo_activation_activate_from_id ( + obj_id, 0, NULL, cspi_ev ()); if (ev._major != CORBA_NO_EXCEPTION) { g_error ("AT-SPI error: during registry activation: %s\n", - bonobo_exception_get_text (spi_ev ())); + bonobo_exception_get_text (cspi_ev ())); } - if (CORBA_Object_is_nil (oclient, spi_ev ())) + if (registry == CORBA_OBJECT_NIL) { g_error ("Could not locate registry"); } - registry = (Accessibility_Registry) oclient; - + Accessibility_Registry_ref (registry, &ev); + bonobo_activate (); - + return 0; } @@ -118,22 +185,23 @@ SPI_init (void) * * Starts/enters the main event loop for the SPI services. * - * (NOTE: This method does not return control, it is exited via a call to exit() + * (NOTE: This method does not return control, it is exited via a call to SPI_exit() * from within an event handler). * **/ void SPI_event_main (boolean isGNOMEApp) { + is_gnome_app = isGNOMEApp; if (isGNOMEApp) { - g_atexit (SPI_exit); + g_atexit (cspi_cleanup); bonobo_main (); } else { /* TODO: install signal handlers to do cleanup */ - CORBA_ORB_run (bonobo_orb(), spi_ev ()); + CORBA_ORB_run (bonobo_orb (), cspi_ev ()); fprintf (stderr, "orb loop exited...\n"); } } @@ -166,7 +234,6 @@ SPI_eventIsReady () * Not Yet Implemented. * * Returns: the next #AccessibleEvent in the SPI event queue. - * **/ AccessibleEvent * SPI_nextEvent (boolean waitForEvent) @@ -177,13 +244,21 @@ SPI_nextEvent (boolean waitForEvent) /** * SPI_exit: * - * Disconnects from the Accessibility Registry and releases resources. - * + * Disconnects from the Accessibility Registry and releases + * any floating resources. **/ void SPI_exit (void) { - fprintf (stderr, "bye-bye!\n"); - exit(0); + cspi_cleanup(); + if (cspi_is_gnome_app ()) + { + bonobo_main_quit (); + } + else + { + CORBA_ORB_shutdown (bonobo_orb (), TRUE, cspi_ev ()); + } + fprintf (stderr, "bye-bye!\n"); } diff --git a/cspi/spi_registry.c b/cspi/spi_registry.c index cd6e7df..2a6eb34 100644 --- a/cspi/spi_registry.c +++ b/cspi/spi_registry.c @@ -28,9 +28,11 @@ * */ +#if 0 /* static stuff used only by registry C bindings */ static GList *key_listeners = NULL; static Display *display = NULL; +#endif /** * registerGlobalEventListener: @@ -96,13 +98,13 @@ registerGlobalEventListener (AccessibleEventListener *listener, boolean retval; Accessibility_Registry_registerGlobalEventListener ( - spi_registry (), + cspi_registry (), (Accessibility_EventListener) bonobo_object_corba_objref (bonobo_object (listener)), eventType, - spi_ev ()); + cspi_ev ()); - retval = !spi_exception (); + retval = !cspi_exception (); return retval; } @@ -113,7 +115,8 @@ registerGlobalEventListener (AccessibleEventListener *listener, * an event type. * * deregisters an AccessibleEventListener from the registry, for all - * event types it may be listening to. + * event types it may be listening to. Also unrefs the listener. + * The listener cannot subsequently be reused. * * Returns: #TRUE if successful, otherwise #FALSE. * @@ -122,14 +125,19 @@ boolean deregisterGlobalEventListenerAll (AccessibleEventListener *listener) { Accessibility_Registry_deregisterGlobalEventListenerAll ( - spi_registry (), + cspi_registry (), (Accessibility_EventListener) CORBA_Object_duplicate ( bonobo_object_corba_objref ( - bonobo_object (listener)), spi_ev ()), - spi_ev ()); + bonobo_object (listener)), cspi_ev ()), + cspi_ev ()); + if (!cspi_exception ()) + { + bonobo_object_unref (BONOBO_OBJECT (listener)); + /* Would prefer that this were not a bonobo object: g_object_unref (listener);*/ + } - return !spi_exception (); + return !cspi_exception (); } /** * deregisterGlobalEventListener: @@ -148,14 +156,14 @@ deregisterGlobalEventListener (AccessibleEventListener *listener, char *eventType) { Accessibility_Registry_deregisterGlobalEventListener ( - spi_registry (), + cspi_registry (), (Accessibility_EventListener) CORBA_Object_duplicate ( - bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ()), + bonobo_object_corba_objref (bonobo_object (listener)), cspi_ev ()), (CORBA_char *) eventType, - spi_ev ()); + cspi_ev ()); - return !spi_exception (); + return !cspi_exception (); } /** @@ -171,8 +179,7 @@ deregisterGlobalEventListener (AccessibleEventListener *listener, int getDesktopCount () { - return Accessibility_Registry_getDesktopCount ( - spi_registry (), spi_ev ()); + return Accessibility_Registry_getDesktopCount (cspi_registry (), cspi_ev ()); } /** @@ -189,7 +196,9 @@ getDesktopCount () Accessible* getDesktop (int i) { - return spi_object_add (Accessibility_Registry_getDesktop (spi_registry (), (CORBA_short) i, spi_ev ())); + return cspi_object_add (Accessibility_Registry_getDesktop (cspi_registry (), + (CORBA_short) i, + cspi_ev ())); } /** @@ -214,6 +223,7 @@ getDesktopList (Accessible **list) return 0; } +#if 0 static gboolean key_event_source_func (void *p) { @@ -233,13 +243,14 @@ key_event_source_func (void *p) } return TRUE; } +#endif /** * registerAccessibleKeystrokeListener: * @listener: a pointer to the #AccessibleKeystrokeListener for which * keystroke events are requested. * @keys: a pointer to the #AccessibleKeySet indicating which - * keystroke events are requested, or #SPI_KEYSET_ALL_KEYS. + * keystroke events are requested, or #CSPI_KEYSET_ALL_KEYS. * @modmask: an #AccessibleKeyMaskType mask indicating which * key event modifiers must be set in combination with @keys, * events will only be reported for key events for which all @@ -252,8 +263,8 @@ key_event_source_func (void *p) * the behavior of the notification/listener transaction. * * Register a listener for keystroke events, either pre-emptively for - * all windows (SPI_KEYLISTENER_ALL_WINDOWS), or - * non-preemptively (SPI_KEYLISTENER_NOSYNC). + * all windows (CSPI_KEYLISTENER_ALL_WINDOWS), or + * non-preemptively (CSPI_KEYLISTENER_NOSYNC). * ( Other sync_type values may be available in the future.) **/ void @@ -266,12 +277,12 @@ registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, Accessibility_ControllerEventMask *controller_event_mask = Accessibility_ControllerEventMask__alloc(); Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ()); + Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ()); Accessibility_KeySet *key_set = Accessibility_KeySet__alloc(); Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc(); - Accessibility_KeystrokeListener spi_listener_corba_ref; + Accessibility_KeystrokeListener cspi_listener_corba_ref; gint i, mask; - Accessibility_DeviceEventController_ref (device_event_controller, spi_ev ()); + Accessibility_DeviceEventController_ref (device_event_controller, cspi_ev ()); /* copy the keyval filter values from the C api into the CORBA KeySet */ if (keys) @@ -311,17 +322,17 @@ registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, controller_event_mask->value = (CORBA_unsigned_long) modmask; controller_event_mask->refcount = (CORBA_unsigned_short) 1; - spi_listener_corba_ref = (Accessibility_KeystrokeListener) - CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ()); + cspi_listener_corba_ref = (Accessibility_KeystrokeListener) + CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), cspi_ev ()); Accessibility_DeviceEventController_registerKeystrokeListener ( device_event_controller, - spi_listener_corba_ref, + cspi_listener_corba_ref, key_set, controller_event_mask, key_events, (CORBA_boolean) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0), - spi_ev ()); + cspi_ev ()); } /** @@ -341,25 +352,25 @@ deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, Accessibility_ControllerEventMask *controller_event_mask = Accessibility_ControllerEventMask__alloc(); Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ()); + Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ()); Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc(); Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc(); - Accessibility_KeystrokeListener spi_listener_corba_ref; - Accessibility_DeviceEventController_unref (device_event_controller, spi_ev ()); + Accessibility_KeystrokeListener cspi_listener_corba_ref; + Accessibility_DeviceEventController_unref (device_event_controller, cspi_ev ()); controller_event_mask->value = (CORBA_unsigned_long) modmask; controller_event_mask->refcount = (CORBA_unsigned_short) 1; - spi_listener_corba_ref = (Accessibility_KeystrokeListener) - CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), spi_ev ()); + cspi_listener_corba_ref = (Accessibility_KeystrokeListener) + CORBA_Object_duplicate (BONOBO_OBJREF(listener), cspi_ev ()); Accessibility_DeviceEventController_deregisterKeystrokeListener ( device_event_controller, - spi_listener_corba_ref, + cspi_listener_corba_ref, all_keys, controller_event_mask, key_events, (CORBA_boolean) TRUE, - spi_ev ()); + cspi_ev ()); } /** @@ -368,7 +379,7 @@ deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, * being synthesized. * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval * is to be interpreted as a keysym rather than a keycode - * (SPI_KEYSYM), or whether to synthesize + * (CSPI_KEYSYM), or whether to synthesize * SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE). * * Synthesize a keyboard event (as if a hardware keyboard event occurred in the @@ -382,11 +393,11 @@ generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type) * send keycode to alter, if necessary */ Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (spi_registry (), spi_ev ()); + Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ()); Accessibility_DeviceEventController_generateKeyEvent (device_event_controller, keyval, (unsigned long) synth_type, - spi_ev ()); + cspi_ev ()); } /** diff --git a/cspi/spi_selection.c b/cspi/spi_selection.c index 4934cff..1b98704 100644 --- a/cspi/spi_selection.c +++ b/cspi/spi_selection.c @@ -12,7 +12,7 @@ int AccessibleSelection_ref (AccessibleSelection *obj) { - Accessibility_Selection_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -29,7 +29,7 @@ AccessibleSelection_ref (AccessibleSelection *obj) int AccessibleSelection_unref (AccessibleSelection *obj) { - Accessibility_Selection_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -50,7 +50,7 @@ long AccessibleSelection_getNSelectedChildren (AccessibleSelection *obj) { return (long) - Accessibility_Selection__get_nSelectedChildren (*obj, spi_ev ()); + Accessibility_Selection__get_nSelectedChildren (CSPI_OBJREF (obj), cspi_ev ()); } @@ -76,11 +76,11 @@ AccessibleSelection_getSelectedChild (AccessibleSelection *obj, long int selectedChildIndex) { Accessibility_Accessible child = - Accessibility_Selection_getSelectedChild (*obj, - (CORBA_long) selectedChildIndex, spi_ev ()); - spi_warn_ev (spi_ev (), "getSelectedChild"); + Accessibility_Selection_getSelectedChild (CSPI_OBJREF (obj), + (CORBA_long) selectedChildIndex, cspi_ev ()); + cspi_warn_ev (cspi_ev (), "getSelectedChild"); - return (Accessible *) spi_object_add (child); + return (Accessible *) cspi_object_add (child); } /** @@ -102,8 +102,8 @@ AccessibleSelection_selectChild (AccessibleSelection *obj, long int childIndex) { return (boolean) - Accessibility_Selection_selectChild (*obj, - (CORBA_long) childIndex, spi_ev ()); + Accessibility_Selection_selectChild (CSPI_OBJREF (obj), + (CORBA_long) childIndex, cspi_ev ()); } @@ -127,7 +127,7 @@ AccessibleSelection_deselectSelectedChild (AccessibleSelection *obj, long int selectedChildIndex) { return Accessibility_Selection_deselectSelectedChild ( - *obj, (CORBA_long) selectedChildIndex, spi_ev ()); + CSPI_OBJREF (obj), (CORBA_long) selectedChildIndex, cspi_ev ()); } @@ -150,8 +150,8 @@ AccessibleSelection_isChildSelected (AccessibleSelection *obj, long int childIndex) { return (boolean) - Accessibility_Selection_isChildSelected (*obj, - (CORBA_long) childIndex, spi_ev ()); + Accessibility_Selection_isChildSelected (CSPI_OBJREF (obj), + (CORBA_long) childIndex, cspi_ev ()); } @@ -169,7 +169,7 @@ AccessibleSelection_isChildSelected (AccessibleSelection *obj, boolean AccessibleSelection_selectAll (AccessibleSelection *obj) { - Accessibility_Selection_selectAll (*obj, spi_ev ()); + Accessibility_Selection_selectAll (CSPI_OBJREF (obj), cspi_ev ()); return TRUE; /* TODO: change the bonobo method to return boolean */ } @@ -186,7 +186,7 @@ AccessibleSelection_selectAll (AccessibleSelection *obj) void AccessibleSelection_clearSelection (AccessibleSelection *obj) { - Accessibility_Selection_clearSelection (*obj, spi_ev ()); + Accessibility_Selection_clearSelection (CSPI_OBJREF (obj), cspi_ev ()); } diff --git a/cspi/spi_table.c b/cspi/spi_table.c index bf5e27a..b59dae1 100644 --- a/cspi/spi_table.c +++ b/cspi/spi_table.c @@ -13,7 +13,7 @@ int AccessibleTable_ref (AccessibleTable *obj) { - Accessibility_Table_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -31,7 +31,7 @@ AccessibleTable_ref (AccessibleTable *obj) int AccessibleTable_unref (AccessibleTable *obj) { - Accessibility_Table_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -48,7 +48,7 @@ Accessible * AccessibleTable_getCaption (AccessibleTable *obj) { return (Accessible *) - Accessibility_Table__get_caption (*obj, spi_ev ()); + Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ()); } @@ -67,7 +67,7 @@ Accessible * AccessibleTable_getSummary (AccessibleTable *obj) { return (Accessible *) - Accessibility_Table__get_summary (*obj, spi_ev ()); + Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ()); } @@ -87,7 +87,7 @@ long AccessibleTable_getNRows (AccessibleTable *obj) { return (long) - Accessibility_Table__get_nRows (*obj, spi_ev ()); + Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ()); } @@ -107,7 +107,7 @@ long AccessibleTable_getNColumns (AccessibleTable *obj) { return (long) - Accessibility_Table__get_nColumns (*obj, spi_ev ()); + Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ()); } @@ -130,8 +130,8 @@ AccessibleTable_getAccessibleAt (AccessibleTable *obj, long int column) { return (Accessible *) - Accessibility_Table_getAccessibleAt (*obj, - (CORBA_long) row, (CORBA_long) column, spi_ev ()); + Accessibility_Table_getAccessibleAt (CSPI_OBJREF (obj), + (CORBA_long) row, (CORBA_long) column, cspi_ev ()); } @@ -156,8 +156,8 @@ AccessibleTable_getIndexAt (AccessibleTable *obj, long int column) { return (long) - Accessibility_Table_getIndexAt (*obj, - (CORBA_long) row, (CORBA_long) column, spi_ev ()); + Accessibility_Table_getIndexAt (CSPI_OBJREF (obj), + (CORBA_long) row, (CORBA_long) column, cspi_ev ()); } @@ -180,8 +180,8 @@ AccessibleTable_getRowAtIndex (AccessibleTable *obj, long index) { return (long) - Accessibility_Table_getRowAtIndex (*obj, - (CORBA_long) index, spi_ev ()); + Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj), + (CORBA_long) index, cspi_ev ()); } @@ -204,8 +204,8 @@ AccessibleTable_getColumnAtIndex (AccessibleTable *obj, long index) { return (long) - Accessibility_Table_getColumnAtIndex (*obj, - (CORBA_long) index, spi_ev ()); + Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj), + (CORBA_long) index, cspi_ev ()); } @@ -226,8 +226,8 @@ AccessibleTable_getRowDescription (AccessibleTable *obj, long int row) { return (char *) - Accessibility_Table_getRowDescription (*obj, - (CORBA_long) row, spi_ev ()); + Accessibility_Table_getRowDescription (CSPI_OBJREF (obj), + (CORBA_long) row, cspi_ev ()); } @@ -248,8 +248,8 @@ AccessibleTable_getColumnDescription (AccessibleTable *obj, long int column) { return (char *) - Accessibility_Table_getColumnDescription (*obj, - (CORBA_long) column, spi_ev ()); + Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj), + (CORBA_long) column, cspi_ev ()); } @@ -272,8 +272,8 @@ AccessibleTable_getRowExtentAt (AccessibleTable *obj, long int column) { return (long) - Accessibility_Table_getRowExtentAt (*obj, - (CORBA_long) row, (CORBA_long) column, spi_ev ()); + Accessibility_Table_getRowExtentAt (CSPI_OBJREF (obj), + (CORBA_long) row, (CORBA_long) column, cspi_ev ()); } @@ -296,8 +296,8 @@ AccessibleTable_getColumnExtentAt (AccessibleTable *obj, long int column) { return (long) - Accessibility_Table_getColumnExtentAt (*obj, - (CORBA_long) row, (CORBA_long) column, spi_ev ()); + Accessibility_Table_getColumnExtentAt (CSPI_OBJREF (obj), + (CORBA_long) row, (CORBA_long) column, cspi_ev ()); } @@ -317,8 +317,8 @@ AccessibleTable_getRowHeader (AccessibleTable *obj, long int row) { return (Accessible *) - Accessibility_Table_getRowHeader (*obj, - (CORBA_long) row, spi_ev ()); + Accessibility_Table_getRowHeader (CSPI_OBJREF (obj), + (CORBA_long) row, cspi_ev ()); } @@ -339,8 +339,8 @@ AccessibleTable_getColumnHeader (AccessibleTable *obj, long int column) { return (Accessible *) - Accessibility_Table_getColumnHeader (*obj, - (CORBA_long) column, spi_ev ()); + Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj), + (CORBA_long) column, cspi_ev ()); } @@ -357,7 +357,7 @@ long AccessibleTable_getNSelectedRows (AccessibleTable *obj) { return (long) - Accessibility_Table__get_nSelectedRows (*obj, spi_ev ()); + Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); } @@ -376,7 +376,7 @@ long AccessibleTable_getSelectedRows (AccessibleTable *obj, long int **selectedRows) { - Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (*obj, spi_ev ()); + Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); CORBA_long *i; long *j; long length; @@ -408,7 +408,7 @@ long AccessibleTable_getNSelectedColumns (AccessibleTable *obj) { return (long) - Accessibility_Table__get_nSelectedColumns (*obj, spi_ev ()); + Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); } @@ -427,7 +427,7 @@ long AccessibleTable_getSelectedColumns (AccessibleTable *obj, long int **selectedColumns) { - Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (*obj, spi_ev ()); + Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); CORBA_long *i; long *j; long length; @@ -460,8 +460,8 @@ AccessibleTable_isRowSelected (AccessibleTable *obj, long int row) { return (boolean) - Accessibility_Table_isRowSelected (*obj, - (CORBA_long) row, spi_ev ()); + Accessibility_Table_isRowSelected (CSPI_OBJREF (obj), + (CORBA_long) row, cspi_ev ()); } @@ -482,8 +482,8 @@ AccessibleTable_isColumnSelected (AccessibleTable *obj, long int column) { return (boolean) - Accessibility_Table_isColumnSelected (*obj, - (CORBA_long) column, spi_ev ()); + Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj), + (CORBA_long) column, cspi_ev ()); } @@ -505,7 +505,7 @@ AccessibleTable_isSelected (AccessibleTable *obj, long int column) { return (boolean) - Accessibility_Table_isSelected (*obj, - (CORBA_long) row, (CORBA_long) column, spi_ev ()); + Accessibility_Table_isSelected (CSPI_OBJREF (obj), + (CORBA_long) row, (CORBA_long) column, cspi_ev ()); } diff --git a/cspi/spi_text.c b/cspi/spi_text.c index 3ee18aa..d3ff995 100644 --- a/cspi/spi_text.c +++ b/cspi/spi_text.c @@ -12,7 +12,7 @@ int AccessibleText_ref (AccessibleText *obj) { - Accessibility_Text_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -30,7 +30,7 @@ AccessibleText_ref (AccessibleText *obj) int AccessibleText_unref (AccessibleText *obj) { - Accessibility_Text_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -50,11 +50,11 @@ AccessibleText_getCharacterCount (AccessibleText *obj) { long retval; - CORBA_exception_init (spi_ev ()); + CORBA_exception_init (cspi_ev ()); retval = (long) - Accessibility_Text__get_characterCount (*obj, spi_ev ()); + Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ()); - spi_check_ev (spi_ev (), "SpiAccessibleText_getCharacterCount"); + cspi_check_ev (cspi_ev (), "SpiAccessibleText_getCharacterCount"); return retval; } @@ -81,8 +81,8 @@ AccessibleText_getText (AccessibleText *obj, long int endOffset) { return (char *) - Accessibility_Text_getText (*obj, - (CORBA_long) startOffset, (CORBA_long) endOffset, spi_ev ()); + Accessibility_Text_getText (CSPI_OBJREF (obj), + (CORBA_long) startOffset, (CORBA_long) endOffset, cspi_ev ()); } /** @@ -98,7 +98,7 @@ long AccessibleText_getCaretOffset (AccessibleText *obj) { return (long) - Accessibility_Text__get_caretOffset (*obj, spi_ev ()); + Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ()); } @@ -127,11 +127,11 @@ AccessibleText_getAttributes (AccessibleText *obj, CORBA_long retStartOffset, retEndOffset; char *retval; retval = (char *) - Accessibility_Text_getAttributes (*obj, + Accessibility_Text_getAttributes (CSPI_OBJREF (obj), (CORBA_long) offset, &retStartOffset, &retEndOffset, - spi_ev ()); + cspi_ev ()); *startOffset = (long) retStartOffset; *endOffset = (long) retEndOffset; return retval; @@ -154,8 +154,8 @@ AccessibleText_setCaretOffset (AccessibleText *obj, long int newOffset) { return (boolean) - Accessibility_Text_setCaretOffset (*obj, - (CORBA_long) newOffset, spi_ev ()); + Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj), + (CORBA_long) newOffset, cspi_ev ()); } /** @@ -190,10 +190,10 @@ AccessibleText_getTextBeforeOffset (AccessibleText *obj, char *retval; CORBA_long retStartOffset, retEndOffset; retval = (char *) - Accessibility_Text_getTextBeforeOffset (*obj, + Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj), (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type, &retStartOffset, &retEndOffset, - spi_ev ()); + cspi_ev ()); *startOffset = (long) retStartOffset; *endOffset = (long) retEndOffset; return retval; @@ -230,15 +230,15 @@ AccessibleText_getTextAtOffset (AccessibleText *obj, CORBA_long corbaStartOffset; CORBA_long corbaEndOffset; char *retval = ""; - retval = Accessibility_Text_getTextAtOffset (*obj, + retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj), (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type, &corbaStartOffset, &corbaEndOffset, - spi_ev ()); + cspi_ev ()); *startOffset = (long) corbaStartOffset; *endOffset = (long) corbaEndOffset; -#ifdef SPI_DEBUG +#ifdef CSPI_DEBUG fprintf (stderr, "text offsets %ld to %ld\n", *startOffset, *endOffset); #endif return retval; @@ -276,10 +276,10 @@ AccessibleText_getTextAfterOffset (AccessibleText *obj, char *retval; CORBA_long retStartOffset, retEndOffset; retval = (char *) - Accessibility_Text_getTextAfterOffset (*obj, + Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj), (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type, &retStartOffset, &retEndOffset, - spi_ev ()); + cspi_ev ()); *startOffset = (long) retStartOffset; *endOffset = (long) retEndOffset; return retval; @@ -306,8 +306,8 @@ AccessibleText_getCharacterAtOffset (AccessibleText *obj, long int offset) { return (unsigned long) - Accessibility_Text_getCharacterAtOffset (*obj, - (CORBA_long) offset, spi_ev ()); + Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj), + (CORBA_long) offset, cspi_ev ()); } /** @@ -340,13 +340,13 @@ AccessibleText_getCharacterExtents (AccessibleText *obj, AccessibleCoordType type) { CORBA_long retX, retY, retWidth, retHeight; - Accessibility_Text_getCharacterExtents (*obj, + Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj), (CORBA_long) offset, &retX, &retY, &retWidth, &retHeight, - (CORBA_short) type, spi_ev ()); + (CORBA_short) type, cspi_ev ()); *x = (long) retX; *y = (long) retY; *width = (long) retWidth; @@ -375,8 +375,8 @@ AccessibleText_getOffsetAtPoint (AccessibleText *obj, AccessibleCoordType type) { return (long) - Accessibility_Text_getOffsetAtPoint (*obj, - (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, spi_ev ()); + Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj), + (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, cspi_ev ()); } @@ -396,7 +396,7 @@ long AccessibleText_getNSelections (AccessibleText *obj) { return (long) - Accessibility_Text_getNSelections (*obj, spi_ev ()); + Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ()); } @@ -421,9 +421,9 @@ AccessibleText_getSelection (AccessibleText *obj, long int *endOffset) { CORBA_long retStartOffset, retEndOffset; - Accessibility_Text_getSelection (*obj, + Accessibility_Text_getSelection (CSPI_OBJREF (obj), (CORBA_long) selectionNum, - &retStartOffset, &retEndOffset, spi_ev ()); + &retStartOffset, &retEndOffset, cspi_ev ()); *startOffset = (long) retStartOffset; *endOffset = (long) retEndOffset; @@ -447,9 +447,9 @@ AccessibleText_addSelection (AccessibleText *obj, long int startOffset, long int endOffset) { return (boolean) - Accessibility_Text_addSelection (*obj, + Accessibility_Text_addSelection (CSPI_OBJREF (obj), (CORBA_long) startOffset, (CORBA_long) endOffset, - spi_ev ()); + cspi_ev ()); } @@ -469,8 +469,8 @@ AccessibleText_removeSelection (AccessibleText *obj, long int selectionNum) { return (boolean) - Accessibility_Text_removeSelection (*obj, - (CORBA_long) selectionNum, spi_ev ()); + Accessibility_Text_removeSelection (CSPI_OBJREF (obj), + (CORBA_long) selectionNum, cspi_ev ()); } /** @@ -493,10 +493,10 @@ AccessibleText_setSelection (AccessibleText *obj, long int endOffset) { return (boolean) - Accessibility_Text_setSelection (*obj, + Accessibility_Text_setSelection (CSPI_OBJREF (obj), (CORBA_long) selectionNum, (CORBA_long) startOffset, - (CORBA_long) endOffset, spi_ev ()); + (CORBA_long) endOffset, cspi_ev ()); } diff --git a/cspi/spi_value.c b/cspi/spi_value.c index 4f4b75e..8d72298 100644 --- a/cspi/spi_value.c +++ b/cspi/spi_value.c @@ -12,7 +12,7 @@ int AccessibleValue_ref (AccessibleValue *obj) { - Accessibility_Value_ref (*obj, spi_ev ()); + cspi_object_ref (obj); return 0; } @@ -30,7 +30,7 @@ AccessibleValue_ref (AccessibleValue *obj) int AccessibleValue_unref (AccessibleValue *obj) { - Accessibility_Value_unref (*obj, spi_ev ()); + cspi_object_unref (obj); return 0; } @@ -49,7 +49,7 @@ float AccessibleValue_getMinimumValue (AccessibleValue *obj) { return (float) - Accessibility_Value__get_minimumValue (*obj, spi_ev ()); + Accessibility_Value__get_minimumValue (CSPI_OBJREF (obj), cspi_ev ()); } @@ -67,7 +67,7 @@ float AccessibleValue_getCurrentValue (AccessibleValue *obj) { return (float) - Accessibility_Value__get_currentValue (*obj, spi_ev ()); + Accessibility_Value__get_currentValue (CSPI_OBJREF (obj), cspi_ev ()); } @@ -85,7 +85,7 @@ float AccessibleValue_getMaximumValue (AccessibleValue *obj) { return (float) - Accessibility_Value__get_maximumValue (*obj, spi_ev ()); + Accessibility_Value__get_maximumValue (CSPI_OBJREF (obj), cspi_ev ()); } @@ -105,8 +105,8 @@ boolean AccessibleValue_setCurrentValue (AccessibleValue *obj, float newValue) { - Accessibility_Value__set_currentValue (*obj, - (CORBA_float) newValue, spi_ev ()); + Accessibility_Value__set_currentValue (CSPI_OBJREF (obj), + (CORBA_float) newValue, cspi_ev ()); return TRUE; } diff --git a/libspi/accessible.c b/libspi/accessible.c index f603527..3b8e364 100644 --- a/libspi/accessible.c +++ b/libspi/accessible.c @@ -40,12 +40,10 @@ spi_accessible_object_finalize (GObject *object) { SpiAccessible *accessible = SPI_ACCESSIBLE (object); - printf("spi_accessible_object_finalize called\n"); ATK_OBJECT (accessible->atko); /* assertion */ g_object_unref (G_OBJECT(accessible->atko)); accessible->atko = NULL; - printf("atko freed, calling parent finalize\n"); spi_accessible_parent_class->finalize (object); } @@ -125,9 +123,7 @@ impl_accessibility_accessible_get_parent (PortableServer_Servant servant, parent = atk_object_get_parent (accessible->atko); retval = BONOBO_OBJREF (spi_accessible_new (parent)); - printf ("SpiAccessible get_parent called\n"); - - return CORBA_Object_duplicate (retval, ev); + return bonobo_object_dup_ref (retval, ev); } /* @@ -170,8 +166,7 @@ impl_accessibility_accessible_get_child_at_index (PortableServer_Servant servant SpiAccessible *accessible = SPI_ACCESSIBLE (bonobo_object_from_servant (servant)); AtkObject *child = atk_object_ref_accessible_child (accessible->atko, (gint) index); retval = BONOBO_OBJREF (spi_accessible_new (child)); - printf ("SpiAccessible get_child_at_index called.\n"); - return CORBA_Object_duplicate (retval, ev); + return bonobo_object_dup_ref (retval, ev); } /* @@ -209,7 +204,7 @@ impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant, for (i=0; i_buffer[i] = - CORBA_Object_duplicate (bonobo_object_corba_objref ( + bonobo_object_dup_ref (bonobo_object_corba_objref ( BONOBO_OBJECT (spi_relation_new (atk_relation_set_get_relation (relation_set, i)))), ev); } diff --git a/libspi/accessibleeventlistener.c b/libspi/accessibleeventlistener.c index cf30cd4..1164afa 100644 --- a/libspi/accessibleeventlistener.c +++ b/libspi/accessibleeventlistener.c @@ -34,15 +34,24 @@ /* A pointer to our parent object class */ static SpiListenerClass *spi_event_listener_parent_class; +enum { + EVENT, + LAST_SIGNAL +}; +static guint signals [LAST_SIGNAL]; + /* * Implemented GObject::finalize */ static void spi_event_listener_object_finalize (GObject *object) { + SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (object); #ifdef SPI_DEBUG fprintf(stderr, "spi_listener_object_finalize called\n"); #endif + g_list_free (listener->callbacks); + ((GObjectClass *) spi_event_listener_parent_class)->finalize (object); } @@ -55,22 +64,21 @@ impl_accessible_event_notify_event (PortableServer_Servant servant, const Accessibility_Event *e, CORBA_Environment *ev) { - int n; - int len; + GList *l; VoidSpiEventListenerCB cb; SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER ( bonobo_object_from_servant (servant)); - len = g_list_length (listener->callbacks); - for (n=0; ncallbacks; l; l = l->next) { - cb = (VoidSpiEventListenerCB) g_list_nth_data (listener->callbacks, n); + cb = (VoidSpiEventListenerCB) l->data; if (cb) { (*cb) (e); } } - /* Accessibility_Accessible_unref (e->source, ev); */ + + g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e); } static void @@ -81,6 +89,15 @@ spi_event_listener_class_init (SpiEventListenerClass *klass) POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv; spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE); + signals [EVENT] = g_signal_new ( + "event", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SpiEventListenerClass, event), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + object_class->finalize = spi_event_listener_object_finalize; epv->notifyEvent = impl_accessible_event_notify_event; @@ -108,7 +125,7 @@ void spi_event_listener_add_callback (SpiEventListener *listener, VoidSpiEventListenerCB callback) { - listener->callbacks = g_list_append (listener->callbacks, callback); + listener->callbacks = g_list_prepend (listener->callbacks, callback); } void diff --git a/libspi/accessibleeventlistener.h b/libspi/accessibleeventlistener.h index 44723b7..0f4d2d4 100644 --- a/libspi/accessibleeventlistener.h +++ b/libspi/accessibleeventlistener.h @@ -27,29 +27,38 @@ G_BEGIN_DECLS +/* FIXME: these macro names are all messed up, probably from the namespacing */ + #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ()) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener)) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListenerClass)) -#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) +#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) #define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) -typedef void (*VoidSpiEventListenerCB) (gpointer event_ptr); +typedef void (*VoidSpiEventListenerCB) (const Accessibility_Event *e); -typedef struct { +typedef struct _SpiEventListener SpiEventListener; + +struct _SpiEventListener { SpiListener parent; - GList *callbacks; -} SpiEventListener; + GList *callbacks; +}; typedef struct { SpiListenerClass parent_class; + + /* signals */ + void (*event) (SpiEventListener *listener, + Accessibility_Event *e); + } SpiEventListenerClass; -GType spi_event_listener_get_type (void); -SpiEventListener *spi_event_listener_new (void); -void spi_event_listener_add_callback (SpiEventListener *listener, - VoidSpiEventListenerCB callback); -void spi_event_listener_remove_callback (SpiEventListener *listener, - VoidSpiEventListenerCB callback); +GType spi_event_listener_get_type (void); +SpiEventListener *spi_event_listener_new (void); +void spi_event_listener_add_callback (SpiEventListener *listener, + VoidSpiEventListenerCB callback); +void spi_event_listener_remove_callback (SpiEventListener *listener, + VoidSpiEventListenerCB callback); G_END_DECLS diff --git a/libspi/application.c b/libspi/application.c index e7d1a66..1b5e14b 100644 --- a/libspi/application.c +++ b/libspi/application.c @@ -70,6 +70,7 @@ static void spi_accessible_application_finalize (GObject *object) { /* TODO: any necessary cleanup */ + g_print ("application finalize called\n"); (G_OBJECT_CLASS (spi_application_parent_class))->finalize (object); } @@ -341,6 +342,7 @@ SpiApplication * spi_application_new (AtkObject *app_root) { SpiApplication *retval = g_object_new (SPI_APPLICATION_TYPE, NULL); + g_object_unref (retval->parent.atko); retval->parent.atko = app_root; g_object_ref (G_OBJECT (app_root)); return retval; diff --git a/libspi/desktop.c b/libspi/desktop.c index 82dfd92..8907d42 100644 --- a/libspi/desktop.c +++ b/libspi/desktop.c @@ -41,6 +41,12 @@ spi_desktop_init (SpiDesktop *desktop) atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main"); } +static void +spi_desktop_finalize (GObject *object) +{ + (G_OBJECT_CLASS (parent_class))->finalize (object); +} + static CORBA_long impl_desktop_get_child_count (PortableServer_Servant servant, CORBA_Environment * ev) @@ -69,7 +75,7 @@ impl_desktop_get_child_at_index (PortableServer_Servant servant, /* */ fprintf (stderr, "object address %p\n", g_list_nth_data (desktop->applications, index)); - retval = CORBA_Object_duplicate ( + retval = bonobo_object_dup_ref ( (CORBA_Object) g_list_nth_data (desktop->applications, index), ev); } else @@ -83,9 +89,12 @@ impl_desktop_get_child_at_index (PortableServer_Servant servant, static void spi_desktop_class_init (SpiDesktopClass *klass) { + GObjectClass * object_class = (GObjectClass *) klass; SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass; POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv; + object_class->finalize = spi_desktop_finalize; + parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE); epv->_get_childCount = impl_desktop_get_child_count; diff --git a/libspi/deviceeventcontroller.c b/libspi/deviceeventcontroller.c index 75ec325..ae6d471 100644 --- a/libspi/deviceeventcontroller.c +++ b/libspi/deviceeventcontroller.c @@ -125,7 +125,7 @@ dec_key_listener_new (CORBA_Object l, CORBA_Environment *ev) { DEControllerKeyListener *key_listener = g_new0 (DEControllerKeyListener, 1); - key_listener->listener.object = CORBA_Object_duplicate (l, ev); + key_listener->listener.object = bonobo_object_dup_ref (l, ev); key_listener->listener.type = SPI_DEVICE_TYPE_KBD; key_listener->keys = ORBit_copy_value (keys, TC_Accessibility_KeySet); key_listener->mask = ORBit_copy_value (mask, TC_Accessibility_ControllerEventMask); @@ -142,6 +142,16 @@ dec_key_listener_new (CORBA_Object l, } static void +dec_key_listener_free (DEControllerKeyListener *key_listener, CORBA_Environment *ev) +{ + bonobo_object_release_unref (key_listener->listener.object, ev); + CORBA_free (key_listener->typeseq); + CORBA_free (key_listener->mask); + CORBA_free (key_listener->keys); + g_free (key_listener); +} + +static void controller_register_device_listener (SpiDeviceEventController *controller, DEControllerListener *listener, CORBA_Environment *ev) @@ -152,7 +162,7 @@ controller_register_device_listener (SpiDeviceEventController *controller, switch (listener->type) { case SPI_DEVICE_TYPE_KBD: key_listener = (DEControllerKeyListener *) listener; - controller->key_listeners = g_list_append (controller->key_listeners, key_listener); + controller->key_listeners = g_list_prepend (controller->key_listeners, key_listener); if (key_listener->is_system_global) { mask_ptr = (Accessibility_ControllerEventMask *) @@ -194,14 +204,12 @@ controller_deregister_device_listener (SpiDeviceEventController *controller, { Accessibility_ControllerEventMask *mask_ptr; DEControllerKeyListener *key_listener; + DEControllerListener *dec_listener; GList *list_ptr; switch (listener->type) { case SPI_DEVICE_TYPE_KBD: key_listener = (DEControllerKeyListener *) listener; - list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners); - /* TODO: need a different custom compare func */ - if (list_ptr) - controller->key_listeners = g_list_remove (controller->key_listeners, list_ptr); + /* first, deref matching event mask, if any */ list_ptr = (GList *) g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask, _eventmask_compare_value); @@ -213,10 +221,22 @@ controller_deregister_device_listener (SpiDeviceEventController *controller, if (!mask_ptr->refcount) { controller->keymask_list = - g_list_remove (controller->keymask_list, mask_ptr); + g_list_remove_link (controller->keymask_list, list_ptr); ; /* TODO: release any key grabs that are in place for this key mask */ } } + /* now, remove this listener from the keylistener list */ + list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners); + if (list_ptr) + { + dec_listener = (DEControllerListener *) list_ptr->data; +#ifdef SPI_DEBUG + g_print ("removing keylistener %p\n", dec_listener->object); +#endif + controller->key_listeners = g_list_remove_link (controller->key_listeners, + list_ptr); + dec_key_listener_free (dec_listener, ev); + } break; case SPI_DEVICE_TYPE_MOUSE: /* controller->mouse_listeners = g_list_append (controller->mouse_listeners, @@ -476,6 +496,8 @@ spi_device_event_controller_object_finalize (GObject *object) #ifdef SPI_DEBUG fprintf(stderr, "spi_device_event_controller_object_finalize called\n"); #endif + /* disconnect any special listeners, get rid of outstanding keygrabs */ + spi_device_event_controller_parent_class->finalize (object); } @@ -524,13 +546,14 @@ impl_deregister_keystroke_listener (PortableServer_Servant servant, type, is_system_global, ev); -#ifdef SPI_DEBUG +#ifdef SPI_DEREGISTER_DEBUG fprintf (stderr, "deregistering keystroke listener %p with maskVal %lu\n", (void *) l, (unsigned long) mask->value); #endif controller_deregister_device_listener(controller, (DEControllerListener *) key_listener, ev); + dec_key_listener_free (key_listener, ev); } /* diff --git a/libspi/eventlistener.c b/libspi/eventlistener.c index cf30cd4..1164afa 100644 --- a/libspi/eventlistener.c +++ b/libspi/eventlistener.c @@ -34,15 +34,24 @@ /* A pointer to our parent object class */ static SpiListenerClass *spi_event_listener_parent_class; +enum { + EVENT, + LAST_SIGNAL +}; +static guint signals [LAST_SIGNAL]; + /* * Implemented GObject::finalize */ static void spi_event_listener_object_finalize (GObject *object) { + SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (object); #ifdef SPI_DEBUG fprintf(stderr, "spi_listener_object_finalize called\n"); #endif + g_list_free (listener->callbacks); + ((GObjectClass *) spi_event_listener_parent_class)->finalize (object); } @@ -55,22 +64,21 @@ impl_accessible_event_notify_event (PortableServer_Servant servant, const Accessibility_Event *e, CORBA_Environment *ev) { - int n; - int len; + GList *l; VoidSpiEventListenerCB cb; SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER ( bonobo_object_from_servant (servant)); - len = g_list_length (listener->callbacks); - for (n=0; ncallbacks; l; l = l->next) { - cb = (VoidSpiEventListenerCB) g_list_nth_data (listener->callbacks, n); + cb = (VoidSpiEventListenerCB) l->data; if (cb) { (*cb) (e); } } - /* Accessibility_Accessible_unref (e->source, ev); */ + + g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e); } static void @@ -81,6 +89,15 @@ spi_event_listener_class_init (SpiEventListenerClass *klass) POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv; spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE); + signals [EVENT] = g_signal_new ( + "event", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SpiEventListenerClass, event), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); + object_class->finalize = spi_event_listener_object_finalize; epv->notifyEvent = impl_accessible_event_notify_event; @@ -108,7 +125,7 @@ void spi_event_listener_add_callback (SpiEventListener *listener, VoidSpiEventListenerCB callback) { - listener->callbacks = g_list_append (listener->callbacks, callback); + listener->callbacks = g_list_prepend (listener->callbacks, callback); } void diff --git a/libspi/eventlistener.h b/libspi/eventlistener.h index 44723b7..0f4d2d4 100644 --- a/libspi/eventlistener.h +++ b/libspi/eventlistener.h @@ -27,29 +27,38 @@ G_BEGIN_DECLS +/* FIXME: these macro names are all messed up, probably from the namespacing */ + #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE (spi_event_listener_get_type ()) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListener)) #define SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, SpiEventListenerClass)) -#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) +#define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) #define IS_SPI_ACCESSIBLE_EVENT_SPI_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE)) -typedef void (*VoidSpiEventListenerCB) (gpointer event_ptr); +typedef void (*VoidSpiEventListenerCB) (const Accessibility_Event *e); -typedef struct { +typedef struct _SpiEventListener SpiEventListener; + +struct _SpiEventListener { SpiListener parent; - GList *callbacks; -} SpiEventListener; + GList *callbacks; +}; typedef struct { SpiListenerClass parent_class; + + /* signals */ + void (*event) (SpiEventListener *listener, + Accessibility_Event *e); + } SpiEventListenerClass; -GType spi_event_listener_get_type (void); -SpiEventListener *spi_event_listener_new (void); -void spi_event_listener_add_callback (SpiEventListener *listener, - VoidSpiEventListenerCB callback); -void spi_event_listener_remove_callback (SpiEventListener *listener, - VoidSpiEventListenerCB callback); +GType spi_event_listener_get_type (void); +SpiEventListener *spi_event_listener_new (void); +void spi_event_listener_add_callback (SpiEventListener *listener, + VoidSpiEventListenerCB callback); +void spi_event_listener_remove_callback (SpiEventListener *listener, + VoidSpiEventListenerCB callback); G_END_DECLS diff --git a/libspi/hypertext.c b/libspi/hypertext.c index cb4f98e..17d3b4d 100644 --- a/libspi/hypertext.c +++ b/libspi/hypertext.c @@ -34,9 +34,6 @@ static GObjectClass *parent_class; static void spi_hypertext_finalize (GObject *obj) { - SpiHypertext *hypertext = SPI_HYPERTEXT(obj); - g_object_unref (hypertext->atko); - hypertext->atko = NULL; parent_class->finalize (obj); } @@ -44,7 +41,7 @@ SpiHypertext * spi_hypertext_interface_new (AtkObject *obj) { SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL); - new_hypertext->atko = obj; + (SPI_TEXT (new_hypertext))->atko = obj; g_object_ref (obj); return new_hypertext; } @@ -55,9 +52,9 @@ static CORBA_long impl_getNLinks (PortableServer_Servant _servant, CORBA_Environment * ev) { - SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant)); + SpiHypertext *hypertext = SPI_HYPERTEXT (bonobo_object_from_servant(_servant)); return (CORBA_long) - atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko)); + atk_hypertext_get_n_links (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko)); } @@ -74,7 +71,7 @@ impl_getLink (PortableServer_Servant servant, hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant)); link = atk_hypertext_get_link ( - ATK_HYPERTEXT (hypertext->atko), linkIndex); + ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko), linkIndex); rv = bonobo_object_corba_objref (BONOBO_OBJECT ( spi_hyperlink_new (ATK_OBJECT (link)))); @@ -91,7 +88,7 @@ impl_getLinkIndex (PortableServer_Servant _servant, { SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant)); return (CORBA_long) - atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko), + atk_hypertext_get_link_index (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko), (gint) characterIndex); } diff --git a/libspi/hypertext.h b/libspi/hypertext.h index 9245597..e5db02f 100644 --- a/libspi/hypertext.h +++ b/libspi/hypertext.h @@ -23,6 +23,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -36,8 +37,7 @@ typedef struct _Hypertext SpiHypertext; typedef struct _HypertextClass SpiHypertextClass; struct _Hypertext { - BonoboObject parent; - AtkObject *atko; + SpiText parent; }; struct _HypertextClass { diff --git a/libspi/keystrokelistener.c b/libspi/keystrokelistener.c index 506eeb1..6809027 100644 --- a/libspi/keystrokelistener.c +++ b/libspi/keystrokelistener.c @@ -26,25 +26,32 @@ #ifdef SPI_DEBUG # include #endif +#include #include /* Our parent Gtk object type */ #define PARENT_TYPE BONOBO_TYPE_OBJECT /* A pointer to our parent object class */ -static GObjectClass *keystroke_listener_parent_class; +static BonoboObjectClass *keystroke_listener_parent_class; -/* - * Implemented GObject::finalize - */ +enum { + KEY_EVENT, + LAST_SIGNAL +}; +static guint signals [LAST_SIGNAL]; + +/* GObject::finalize */ static void -keystroke_listener_object_finalize (GObject *object) +spi_keystroke_listener_object_finalize (GObject *object) { + SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (object); + g_list_free (listener->callbacks); #ifdef SPI_DEBUG - fprintf(stderr, "keystroke_listener_object_finalize called\n"); + fprintf(stderr, "keystroke_listener_object_finalize called\n"); #endif - keystroke_listener_parent_class->finalize (object); + ((GObjectClass *) keystroke_listener_parent_class)->finalize (object); } void spi_keystroke_listener_add_callback (SpiKeystrokeListener *listener, @@ -57,8 +64,9 @@ void spi_keystroke_listener_add_callback (SpiKeystrokeListener *listener, #endif } -void spi_keystroke_listener_remove_callback (SpiKeystrokeListener *listener, - BooleanKeystrokeListenerCB callback) +void +spi_keystroke_listener_remove_callback (SpiKeystrokeListener *listener, + BooleanKeystrokeListenerCB callback) { listener->callbacks = g_list_remove (listener->callbacks, callback); } @@ -74,6 +82,13 @@ impl_key_event (PortableServer_Servant servant, SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (bonobo_object_from_servant (servant)); GList *callbacks = listener->callbacks; gboolean was_consumed = FALSE; + + g_signal_emit (G_OBJECT (listener), signals [KEY_EVENT], 0, key, &was_consumed); + if (was_consumed) + { + return TRUE; + } + #ifdef SPI_KEYEVENT_DEBUG if (ev->_major != CORBA_NO_EXCEPTION) { fprintf(stderr, @@ -105,22 +120,86 @@ impl_key_event (PortableServer_Servant servant, return was_consumed; } -static void -spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass) + +static gboolean +boolean_handled_accumulator (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy) +{ + gboolean continue_emission; + gboolean signal_handled; + + signal_handled = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, signal_handled); + continue_emission = !signal_handled; + + return continue_emission; +} + +void +marshal_BOOLEAN__POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) { - GObjectClass * object_class = (GObjectClass *) klass; - POA_Accessibility_KeystrokeListener__epv *epv = &klass->epv; - keystroke_listener_parent_class = g_type_class_peek_parent (klass); + typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, + gpointer arg_1, + gpointer data2); + register GMarshalFunc_BOOLEAN__POINTER callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 2); - object_class->finalize = keystroke_listener_object_finalize; + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); - epv->keyEvent = impl_key_event; + v_return = callback (data1, + g_value_get_pointer (param_values + 1), + data2); + + g_value_set_boolean (return_value, v_return); +} + +static void +spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass) +{ + GObjectClass * object_class = (GObjectClass *) klass; + POA_Accessibility_KeystrokeListener__epv *epv = &klass->epv; + keystroke_listener_parent_class = g_type_class_peek_parent (klass); + + signals [KEY_EVENT] = g_signal_new ( + "key_event", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SpiKeystrokeListenerClass, key_event), + boolean_handled_accumulator, NULL, + marshal_BOOLEAN__POINTER, + G_TYPE_BOOLEAN, 1, G_TYPE_POINTER); + + object_class->finalize = spi_keystroke_listener_object_finalize; + + epv->keyEvent = impl_key_event; } static void spi_keystroke_listener_init (SpiKeystrokeListener *keystroke_listener) { - keystroke_listener->callbacks = NULL; + keystroke_listener->callbacks = NULL; } BONOBO_TYPE_FUNC_FULL (SpiKeystrokeListener, diff --git a/libspi/keystrokelistener.h b/libspi/keystrokelistener.h index ea2052c..60a45dd 100644 --- a/libspi/keystrokelistener.h +++ b/libspi/keystrokelistener.h @@ -46,6 +46,9 @@ typedef struct { typedef struct { BonoboObjectClass parent_class; POA_Accessibility_KeystrokeListener__epv epv; + + gboolean (*key_event) (SpiKeystrokeListener *listener, + const Accessibility_KeyStroke *key); } SpiKeystrokeListenerClass; GType spi_keystroke_listener_get_type (void); diff --git a/libspi/registry.c b/libspi/registry.c index 51a3cb4..62d4178 100644 --- a/libspi/registry.c +++ b/libspi/registry.c @@ -79,18 +79,31 @@ static long _get_unique_id(); static gboolean _device_event_controller_hook (gpointer source); -/* - * Implemented GObject::finalize - */ +SpiListenerStruct * +spi_listener_struct_new (Accessibility_EventListener *listener, CORBA_Environment *ev) +{ + SpiListenerStruct *retval = g_malloc (sizeof (SpiListenerStruct)); + retval->listener = bonobo_object_dup_ref (listener, ev); + return retval; +} + +void +spi_listener_struct_free (SpiListenerStruct *ls, CORBA_Environment *ev) +{ + /* TODO: sanity check for ls */ + Accessibility_EventListener_unref (ls->listener, ev); + g_free (ls); +} + +/* GObject::finalize */ static void spi_registry_object_finalize (GObject *object) { -/* SpiRegistry *registry = SPI_REGISTRY (object); */ - GObjectClass *object_class = G_OBJECT_GET_CLASS( object); + SpiRegistry *registry = SPI_REGISTRY (object); printf("spi_registry_object_finalize called\n"); - - object_class->finalize (object); + /* TODO: unref deviceeventcontroller, which disconnects key listener */ + G_OBJECT_CLASS (spi_registry_parent_class)->finalize (object); } /** @@ -297,7 +310,7 @@ impl_accessibility_registry_register_global_event_listener ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct)); + SpiListenerStruct *ls = spi_listener_struct_new (listener, ev); EventTypeStruct etype; fprintf(stderr, "registering for events of type %s\n", event_name); @@ -312,20 +325,20 @@ impl_accessibility_registry_register_global_event_listener ( case (ETYPE_FOCUS) : case (ETYPE_OBJECT) : case (ETYPE_PROPERTY) : - ls->listener = CORBA_Object_duplicate (listener, ev); registry->object_listeners = g_list_append (registry->object_listeners, ls); break; case (ETYPE_WINDOW) : /* Support for Window Manager Events is not yet implemented */ + spi_listener_struct_free (ls, ev); break; case (ETYPE_TOOLKIT) : - ls->listener = CORBA_Object_duplicate (listener, ev); registry->toolkit_listeners = g_list_append (registry->toolkit_listeners, ls); register_with_toolkits (registry, &etype, ev); break; default: + spi_listener_struct_free (ls, ev); break; } } @@ -340,9 +353,8 @@ impl_accessibility_registry_deregister_global_event_listener_all ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct)); + SpiListenerStruct *spi_listener_struct, *ls = spi_listener_struct_new (listener, ev); GList *list; - ls->listener = listener; list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref); @@ -353,17 +365,18 @@ impl_accessibility_registry_deregister_global_event_listener_all ( while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); registry->object_listeners = g_list_delete_link (registry->object_listeners, list); list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref); } list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref); while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); registry->toolkit_listeners = g_list_delete_link (registry->toolkit_listeners, list); list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref); } + spi_listener_struct_free (ls, ev); } /* @@ -377,7 +390,7 @@ impl_accessibility_registry_deregister_global_event_listener ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct ls; + SpiListenerStruct ls, *spi_listener_struct; EventTypeStruct etype; GList *list; GList **listeners; @@ -409,7 +422,7 @@ impl_accessibility_registry_deregister_global_event_listener ( while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); *listeners = g_list_delete_link (*listeners, list); list = g_list_find_custom (*listeners, &ls, compare_listener_hash); } @@ -453,7 +466,7 @@ impl_accessibility_registry_get_desktop (PortableServer_Servant servant, if (n == 0) { return (Accessibility_Desktop) - CORBA_Object_duplicate (BONOBO_OBJREF (registry->desktop), ev); + bonobo_object_dup_ref (BONOBO_OBJREF (registry->desktop), ev); } else { @@ -485,7 +498,7 @@ impl_accessibility_registry_get_device_event_controller (PortableServer_Servant if (!registry->device_event_controller) registry->device_event_controller = spi_device_event_controller_new (registry); - return CORBA_Object_duplicate (BONOBO_OBJREF (registry->device_event_controller), ev); + return bonobo_object_dup_ref (BONOBO_OBJREF (registry->device_event_controller), ev); } static void @@ -525,6 +538,8 @@ _get_unique_id () return ++id; } +#define SPI_DEBUG + static void _registry_notify_listeners (GList *listeners, const Accessibility_Event *e_in, @@ -554,8 +569,7 @@ _registry_notify_listeners (GList *listeners, fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e_in->source, ev)); #endif e_out = ORBit_copy_value (e_in, TC_Accessibility_Event); - e_out->source = CORBA_Object_duplicate (e_in->source, ev); - Accessibility_Accessible_ref ( e_out->source, ev); + e_out->source = bonobo_object_dup_ref (e_in->source, ev); Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener, e_out, ev); diff --git a/registryd/desktop.c b/registryd/desktop.c index 82dfd92..8907d42 100644 --- a/registryd/desktop.c +++ b/registryd/desktop.c @@ -41,6 +41,12 @@ spi_desktop_init (SpiDesktop *desktop) atk_object_set_name (ATK_OBJECT (SPI_ACCESSIBLE (desktop)->atko), "main"); } +static void +spi_desktop_finalize (GObject *object) +{ + (G_OBJECT_CLASS (parent_class))->finalize (object); +} + static CORBA_long impl_desktop_get_child_count (PortableServer_Servant servant, CORBA_Environment * ev) @@ -69,7 +75,7 @@ impl_desktop_get_child_at_index (PortableServer_Servant servant, /* */ fprintf (stderr, "object address %p\n", g_list_nth_data (desktop->applications, index)); - retval = CORBA_Object_duplicate ( + retval = bonobo_object_dup_ref ( (CORBA_Object) g_list_nth_data (desktop->applications, index), ev); } else @@ -83,9 +89,12 @@ impl_desktop_get_child_at_index (PortableServer_Servant servant, static void spi_desktop_class_init (SpiDesktopClass *klass) { + GObjectClass * object_class = (GObjectClass *) klass; SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass; POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv; + object_class->finalize = spi_desktop_finalize; + parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE); epv->_get_childCount = impl_desktop_get_child_count; diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 75ec325..ae6d471 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -125,7 +125,7 @@ dec_key_listener_new (CORBA_Object l, CORBA_Environment *ev) { DEControllerKeyListener *key_listener = g_new0 (DEControllerKeyListener, 1); - key_listener->listener.object = CORBA_Object_duplicate (l, ev); + key_listener->listener.object = bonobo_object_dup_ref (l, ev); key_listener->listener.type = SPI_DEVICE_TYPE_KBD; key_listener->keys = ORBit_copy_value (keys, TC_Accessibility_KeySet); key_listener->mask = ORBit_copy_value (mask, TC_Accessibility_ControllerEventMask); @@ -142,6 +142,16 @@ dec_key_listener_new (CORBA_Object l, } static void +dec_key_listener_free (DEControllerKeyListener *key_listener, CORBA_Environment *ev) +{ + bonobo_object_release_unref (key_listener->listener.object, ev); + CORBA_free (key_listener->typeseq); + CORBA_free (key_listener->mask); + CORBA_free (key_listener->keys); + g_free (key_listener); +} + +static void controller_register_device_listener (SpiDeviceEventController *controller, DEControllerListener *listener, CORBA_Environment *ev) @@ -152,7 +162,7 @@ controller_register_device_listener (SpiDeviceEventController *controller, switch (listener->type) { case SPI_DEVICE_TYPE_KBD: key_listener = (DEControllerKeyListener *) listener; - controller->key_listeners = g_list_append (controller->key_listeners, key_listener); + controller->key_listeners = g_list_prepend (controller->key_listeners, key_listener); if (key_listener->is_system_global) { mask_ptr = (Accessibility_ControllerEventMask *) @@ -194,14 +204,12 @@ controller_deregister_device_listener (SpiDeviceEventController *controller, { Accessibility_ControllerEventMask *mask_ptr; DEControllerKeyListener *key_listener; + DEControllerListener *dec_listener; GList *list_ptr; switch (listener->type) { case SPI_DEVICE_TYPE_KBD: key_listener = (DEControllerKeyListener *) listener; - list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners); - /* TODO: need a different custom compare func */ - if (list_ptr) - controller->key_listeners = g_list_remove (controller->key_listeners, list_ptr); + /* first, deref matching event mask, if any */ list_ptr = (GList *) g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask, _eventmask_compare_value); @@ -213,10 +221,22 @@ controller_deregister_device_listener (SpiDeviceEventController *controller, if (!mask_ptr->refcount) { controller->keymask_list = - g_list_remove (controller->keymask_list, mask_ptr); + g_list_remove_link (controller->keymask_list, list_ptr); ; /* TODO: release any key grabs that are in place for this key mask */ } } + /* now, remove this listener from the keylistener list */ + list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners); + if (list_ptr) + { + dec_listener = (DEControllerListener *) list_ptr->data; +#ifdef SPI_DEBUG + g_print ("removing keylistener %p\n", dec_listener->object); +#endif + controller->key_listeners = g_list_remove_link (controller->key_listeners, + list_ptr); + dec_key_listener_free (dec_listener, ev); + } break; case SPI_DEVICE_TYPE_MOUSE: /* controller->mouse_listeners = g_list_append (controller->mouse_listeners, @@ -476,6 +496,8 @@ spi_device_event_controller_object_finalize (GObject *object) #ifdef SPI_DEBUG fprintf(stderr, "spi_device_event_controller_object_finalize called\n"); #endif + /* disconnect any special listeners, get rid of outstanding keygrabs */ + spi_device_event_controller_parent_class->finalize (object); } @@ -524,13 +546,14 @@ impl_deregister_keystroke_listener (PortableServer_Servant servant, type, is_system_global, ev); -#ifdef SPI_DEBUG +#ifdef SPI_DEREGISTER_DEBUG fprintf (stderr, "deregistering keystroke listener %p with maskVal %lu\n", (void *) l, (unsigned long) mask->value); #endif controller_deregister_device_listener(controller, (DEControllerListener *) key_listener, ev); + dec_key_listener_free (key_listener, ev); } /* diff --git a/registryd/registry.c b/registryd/registry.c index 51a3cb4..62d4178 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -79,18 +79,31 @@ static long _get_unique_id(); static gboolean _device_event_controller_hook (gpointer source); -/* - * Implemented GObject::finalize - */ +SpiListenerStruct * +spi_listener_struct_new (Accessibility_EventListener *listener, CORBA_Environment *ev) +{ + SpiListenerStruct *retval = g_malloc (sizeof (SpiListenerStruct)); + retval->listener = bonobo_object_dup_ref (listener, ev); + return retval; +} + +void +spi_listener_struct_free (SpiListenerStruct *ls, CORBA_Environment *ev) +{ + /* TODO: sanity check for ls */ + Accessibility_EventListener_unref (ls->listener, ev); + g_free (ls); +} + +/* GObject::finalize */ static void spi_registry_object_finalize (GObject *object) { -/* SpiRegistry *registry = SPI_REGISTRY (object); */ - GObjectClass *object_class = G_OBJECT_GET_CLASS( object); + SpiRegistry *registry = SPI_REGISTRY (object); printf("spi_registry_object_finalize called\n"); - - object_class->finalize (object); + /* TODO: unref deviceeventcontroller, which disconnects key listener */ + G_OBJECT_CLASS (spi_registry_parent_class)->finalize (object); } /** @@ -297,7 +310,7 @@ impl_accessibility_registry_register_global_event_listener ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct)); + SpiListenerStruct *ls = spi_listener_struct_new (listener, ev); EventTypeStruct etype; fprintf(stderr, "registering for events of type %s\n", event_name); @@ -312,20 +325,20 @@ impl_accessibility_registry_register_global_event_listener ( case (ETYPE_FOCUS) : case (ETYPE_OBJECT) : case (ETYPE_PROPERTY) : - ls->listener = CORBA_Object_duplicate (listener, ev); registry->object_listeners = g_list_append (registry->object_listeners, ls); break; case (ETYPE_WINDOW) : /* Support for Window Manager Events is not yet implemented */ + spi_listener_struct_free (ls, ev); break; case (ETYPE_TOOLKIT) : - ls->listener = CORBA_Object_duplicate (listener, ev); registry->toolkit_listeners = g_list_append (registry->toolkit_listeners, ls); register_with_toolkits (registry, &etype, ev); break; default: + spi_listener_struct_free (ls, ev); break; } } @@ -340,9 +353,8 @@ impl_accessibility_registry_deregister_global_event_listener_all ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct *ls = g_malloc (sizeof (SpiListenerStruct)); + SpiListenerStruct *spi_listener_struct, *ls = spi_listener_struct_new (listener, ev); GList *list; - ls->listener = listener; list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref); @@ -353,17 +365,18 @@ impl_accessibility_registry_deregister_global_event_listener_all ( while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); registry->object_listeners = g_list_delete_link (registry->object_listeners, list); list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref); } list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref); while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); registry->toolkit_listeners = g_list_delete_link (registry->toolkit_listeners, list); list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref); } + spi_listener_struct_free (ls, ev); } /* @@ -377,7 +390,7 @@ impl_accessibility_registry_deregister_global_event_listener ( CORBA_Environment *ev) { SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant)); - SpiListenerStruct ls; + SpiListenerStruct ls, *spi_listener_struct; EventTypeStruct etype; GList *list; GList **listeners; @@ -409,7 +422,7 @@ impl_accessibility_registry_deregister_global_event_listener ( while (list) { - fprintf (stderr, "deregistering listener\n"); + spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); *listeners = g_list_delete_link (*listeners, list); list = g_list_find_custom (*listeners, &ls, compare_listener_hash); } @@ -453,7 +466,7 @@ impl_accessibility_registry_get_desktop (PortableServer_Servant servant, if (n == 0) { return (Accessibility_Desktop) - CORBA_Object_duplicate (BONOBO_OBJREF (registry->desktop), ev); + bonobo_object_dup_ref (BONOBO_OBJREF (registry->desktop), ev); } else { @@ -485,7 +498,7 @@ impl_accessibility_registry_get_device_event_controller (PortableServer_Servant if (!registry->device_event_controller) registry->device_event_controller = spi_device_event_controller_new (registry); - return CORBA_Object_duplicate (BONOBO_OBJREF (registry->device_event_controller), ev); + return bonobo_object_dup_ref (BONOBO_OBJREF (registry->device_event_controller), ev); } static void @@ -525,6 +538,8 @@ _get_unique_id () return ++id; } +#define SPI_DEBUG + static void _registry_notify_listeners (GList *listeners, const Accessibility_Event *e_in, @@ -554,8 +569,7 @@ _registry_notify_listeners (GList *listeners, fprintf(stderr, "event source name %s\n", Accessibility_Accessible__get_name(e_in->source, ev)); #endif e_out = ORBit_copy_value (e_in, TC_Accessibility_Event); - e_out->source = CORBA_Object_duplicate (e_in->source, ev); - Accessibility_Accessible_ref ( e_out->source, ev); + e_out->source = bonobo_object_dup_ref (e_in->source, ev); Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener, e_out, ev); diff --git a/test/keysynth-demo.c b/test/keysynth-demo.c index 31df81d..a884437 100644 --- a/test/keysynth-demo.c +++ b/test/keysynth-demo.c @@ -20,6 +20,8 @@ * Boston, MA 02111-1307, USA. */ +#include +#include #include #include #include @@ -313,9 +315,8 @@ button_exit(GtkButton *notused, void *alsonotused) } static boolean -is_command_key (void *p) +is_command_key (AccessibleKeystroke *key) { - AccessibleKeyStroke *key = (AccessibleKeyStroke *)p; switch (key->keyID) { case 'Q': @@ -323,14 +324,14 @@ is_command_key (void *p) keysynth_exit(); return TRUE; /* not reached */ } + return FALSE; } static boolean -switch_callback (void *p) +switch_callback (AccessibleKeystroke *key) { - AccessibleKeyStroke *key = (AccessibleKeyStroke *)p; - static is_down = FALSE; - if (key->type == Accessibility_KEY_RELEASED) + static boolean is_down = FALSE; + if (key->type == SPI_KEY_RELEASED) { g_print ("spacebar up\n"); is_down = FALSE; @@ -376,7 +377,7 @@ synth_keycode (GtkButton *button, KeyCode *keycode) static void create_vkbd() { - GtkWidget *window, *button, *container, *hbox; + GtkWidget *window, *container, *hbox; int i, j; KeyCode *keycodeptr, keycode = MIN_KEYCODE; static boolean true_val = True; @@ -459,23 +460,23 @@ main(int argc, char **argv) AccessibleKeySet switch_set; if ((argc > 1) && (!strncmp(argv[1],"-h",2))) - { - printf ("Usage: keysynth-demo\n"); - exit(0); - } + { + printf ("Usage: keysynth-demo\n"); + exit (1); + } gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */ - SPI_init(); + SPI_init (); - key_listener = createAccessibleKeystrokeListener(is_command_key); + key_listener = createAccessibleKeystrokeListener (is_command_key); /* will listen only to Alt-key combinations */ - registerAccessibleKeystrokeListener(key_listener, - (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS, - SPI_KEYMASK_ALT, - (unsigned long) ( KeyPress | KeyRelease), - SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS); - create_vkbd(); + registerAccessibleKeystrokeListener (key_listener, + (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS, + SPI_KEYMASK_ALT, + (unsigned long) ( KeyPress | KeyRelease), + SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS); + create_vkbd (); /* * Register a listener on an 'unused' key, to serve as a 'single switch'. @@ -488,12 +489,14 @@ main(int argc, char **argv) switch_set.len = 1; switch_set.keysyms[0] = (unsigned long) 0; switch_set.keycodes[0] = (unsigned short) 0; - switch_listener = createAccessibleKeystrokeListener(switch_callback); - registerAccessibleKeystrokeListener(switch_listener, - &switch_set, - SPI_KEYMASK_UNMODIFIED, - (unsigned long) ( KeyPress | KeyRelease), - SPI_KEYLISTENER_CANCONSUME); + switch_listener = createAccessibleKeystrokeListener (switch_callback); + registerAccessibleKeystrokeListener (switch_listener, + &switch_set, + SPI_KEYMASK_UNMODIFIED, + (unsigned long) ( KeyPress | KeyRelease), + SPI_KEYLISTENER_CANCONSUME); - SPI_event_main(TRUE); + SPI_event_main (TRUE); + + return 0; } diff --git a/test/simple-at.c b/test/simple-at.c index a441877..80f051c 100644 --- a/test/simple-at.c +++ b/test/simple-at.c @@ -21,15 +21,18 @@ */ #include +#include +#include #include #include -#include "spi.h" - -static void report_focus_event (void *fp); -static void report_button_press (void *fp); -static boolean report_command_key_event (void *fp); -static boolean report_ordinary_key_event (void *fp); -static void check_property_change (void *fp); +#include +#include "../util/mag_client.h" + +static void report_focus_event (AccessibleEvent *event); +static void report_button_press (AccessibleEvent *event); +static void check_property_change (AccessibleEvent *event); +static boolean report_command_key_event (AccessibleKeystroke *stroke); +static boolean report_ordinary_key_event (AccessibleKeystroke *stroke); static void get_environment_vars (void); static int _festival_init (); @@ -83,11 +86,12 @@ main(int argc, char **argv) fprintf (stderr, "app %d name: %s\n", j, Accessible_getName (application)); Accessible_unref (application); } + Accessible_unref (desktop); } /* prepare the keyboard snoopers */ - command_key_listener = createAccessibleKeystrokeListener(report_command_key_event); - ordinary_key_listener = createAccessibleKeystrokeListener(report_ordinary_key_event); + command_key_listener = createAccessibleKeystrokeListener (report_command_key_event); + ordinary_key_listener = createAccessibleKeystrokeListener (report_ordinary_key_event); /* will listen only to Alt-key combinations, and only to KeyPress events */ registerAccessibleKeystrokeListener(command_key_listener, @@ -167,7 +171,7 @@ report_focussed_accessible (Accessible *obj, boolean shutup_previous_speech) long start_offset, end_offset; char *first_sentence = "empty"; text_interface = Accessible_getText (obj); - fprintf (stderr, "isText...%p %p\n", text_interface, (void *)*text_interface); + fprintf (stderr, "isText...%p\n", text_interface); first_sentence = AccessibleText_getTextAtOffset ( text_interface, (long) 0, SPI_TEXT_BOUNDARY_SENTENCE_START, &start_offset, &end_offset); if (first_sentence) _festival_say(first_sentence, "voice_don_diphone", FALSE); @@ -176,44 +180,41 @@ report_focussed_accessible (Accessible *obj, boolean shutup_previous_speech) } void -report_focus_event (void *p) +report_focus_event (AccessibleEvent *event) { - AccessibleEvent *ev = (AccessibleEvent *) p; - fprintf (stderr, "%s event from %s\n", ev->type, - Accessible_getName (&ev->source)); - report_focussed_accessible (&ev->source, TRUE); + fprintf (stderr, "%s event from %s\n", event->type, + Accessible_getName (event->source)); + report_focussed_accessible (event->source, TRUE); } void -report_button_press (void *p) +report_button_press (AccessibleEvent *event) { - AccessibleEvent *ev = (AccessibleEvent *) p; - fprintf (stderr, "%s event from %s\n", ev->type, - Accessible_getName (&ev->source)); + fprintf (stderr, "%s event from %s\n", event->type, + Accessible_getName (event->source)); fprintf (stderr, "Object description %s\n", - Accessible_getDescription (&ev->source)); + Accessible_getDescription (event->source)); } void -check_property_change (void *p) +check_property_change (AccessibleEvent *event) { - AccessibleEvent *ev = (AccessibleEvent *) p; - AccessibleSelection *selection = Accessible_getSelection (&ev->source); + AccessibleSelection *selection = Accessible_getSelection (event->source); int n_selections; int i; if (selection) { n_selections = (int) AccessibleSelection_getNSelectedChildren (selection); - fprintf (stderr, "(Property) %s event from %s, %d selected children\n", ev->type, - Accessible_getName (&ev->source), n_selections); + fprintf (stderr, "(Property) %s event from %s, %d selected children\n", + event->type, Accessible_getName (event->source), n_selections); /* for now, speak entire selection set */ for (i=0; ikeyID) { @@ -254,9 +258,8 @@ is_command_key (AccessibleKeyStroke *key) } static boolean -report_command_key_event (void *p) +report_command_key_event (AccessibleKeystroke *key) { - AccessibleKeyStroke *key = (AccessibleKeyStroke *) p; fprintf (stderr, "Command KeyEvent %s%c (keycode %d)\n", (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"", ((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))? @@ -267,14 +270,14 @@ report_command_key_event (void *p) static boolean -report_ordinary_key_event (void *p) +report_ordinary_key_event (AccessibleKeystroke *key) { - AccessibleKeyStroke *key = (AccessibleKeyStroke *) p; fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\ttime %ld\n", (long) key->keyID, (unsigned int) key->modifiers, (int) key->keycode, (long int) key->timestamp); + return FALSE; } static int _festival_init () diff --git a/util/mag_client.h b/util/mag_client.h index 8bf6c5d..b4c8008 100644 --- a/util/mag_client.h +++ b/util/mag_client.h @@ -20,6 +20,7 @@ #ifndef MAG_CLIENT_H_ #define MAG_CLIENT_H_ +#include "util/Magnifier.h" #ifdef __cplusplus extern "C" { diff --git a/util/mag_control.c b/util/mag_control.c index 39c63ce..f223944 100644 --- a/util/mag_control.c +++ b/util/mag_control.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "Magnifier.h" #include "mag_client.h" diff --git a/util/magnifier.c b/util/magnifier.c index 781a038..b9bb3f5 100644 --- a/util/magnifier.c +++ b/util/magnifier.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "magnifier.h" #include "mag_image.h" -- 2.7.4