X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cspi%2Fspi_registry.c;h=2a6eb34dfc4c3b860415b7594fef53435eb154a1;hb=7a94d82f749ebce115752713412d7126d4217714;hp=72f93142078c5413b4fcc17e87633fc012c98c43;hpb=fb1e8ce4bd1b97a4029321017b414bd04cef087d;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/cspi/spi_registry.c b/cspi/spi_registry.c index 72f9314..2a6eb34 100644 --- a/cspi/spi_registry.c +++ b/cspi/spi_registry.c @@ -1,3 +1,26 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2001 Sun Microsystems Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include /* * @@ -5,9 +28,11 @@ * */ +#if 0 /* static stuff used only by registry C bindings */ static GList *key_listeners = NULL; static Display *display = NULL; +#endif /** * registerGlobalEventListener: @@ -17,10 +42,44 @@ static Display *display = NULL; * notification is requested. Format is * EventClass:major_type:minor_type:detail * where all subfields other than EventClass are optional. - * EventClasses include "Focus", "Window", "Mouse", + * EventClasses include "object", "window", "mouse", * and toolkit events (e.g. "Gtk", "AWT"). * Examples: "focus:", "Gtk:GtkWidget:button_press_event". * + * Legal object event types: + * + * (property change events) + * + * object:property-change + * object:property-change:accessible-name + * object:property-change:accessible-state + * object:property-change:accessible-description + * object:property-change:accessible-parent + * object:property-change:accessible-value + * object:property-change:accessible-role + * object:property-change:accessible-table-caption + * object:property-change:accessible-table-column-description + * object:property-change:accessible-table-column-header + * object:property-change:accessible-table-row-description + * object:property-change:accessible-table-row-header + * object:property-change:accessible-table-summary + * + * (other object events) + * + * object:children-changed + * object:visible-data-changed + * object:selection-changed + * object:text-selection-changed + * object:text-changed + * object:text-caret-moved + * object:row-inserted + * object:row-reordered + * object:row-deleted + * object:column-inserted + * object:column-reordered + * object:column-deleted + * object:model-changed + * * NOTE: this string may be UTF-8, but should not contain byte value 56 * (ascii ':'), except as a delimiter, since non-UTF-8 string * delimiting functions are used internally. @@ -36,21 +95,18 @@ boolean registerGlobalEventListener (AccessibleEventListener *listener, char *eventType) { + boolean retval; + Accessibility_Registry_registerGlobalEventListener ( - registry, + cspi_registry (), (Accessibility_EventListener) bonobo_object_corba_objref (bonobo_object (listener)), eventType, - &ev); + cspi_ev ()); - if (ev._major != CORBA_NO_EXCEPTION) - { - return FALSE; - } - else - { - return TRUE; - } + retval = !cspi_exception (); + + return retval; } /** @@ -59,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. * @@ -68,21 +125,19 @@ boolean deregisterGlobalEventListenerAll (AccessibleEventListener *listener) { Accessibility_Registry_deregisterGlobalEventListenerAll ( - registry, + cspi_registry (), (Accessibility_EventListener) CORBA_Object_duplicate ( bonobo_object_corba_objref ( - bonobo_object (listener)), &ev), - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - { - return FALSE; - } - else + bonobo_object (listener)), cspi_ev ()), + cspi_ev ()); + if (!cspi_exception ()) { - return TRUE; + bonobo_object_unref (BONOBO_OBJECT (listener)); + /* Would prefer that this were not a bonobo object: g_object_unref (listener);*/ } + + return !cspi_exception (); } /** * deregisterGlobalEventListener: @@ -101,21 +156,14 @@ deregisterGlobalEventListener (AccessibleEventListener *listener, char *eventType) { Accessibility_Registry_deregisterGlobalEventListener ( - registry, + cspi_registry (), (Accessibility_EventListener) CORBA_Object_duplicate ( - bonobo_object_corba_objref (bonobo_object (listener)), &ev), + bonobo_object_corba_objref (bonobo_object (listener)), cspi_ev ()), (CORBA_char *) eventType, - &ev); + cspi_ev ()); - if (ev._major != CORBA_NO_EXCEPTION) - { - return FALSE; - } - else - { - return TRUE; - } + return !cspi_exception (); } /** @@ -131,7 +179,7 @@ deregisterGlobalEventListener (AccessibleEventListener *listener, int getDesktopCount () { - return Accessibility_Registry_getDesktopCount (registry, &ev); + return Accessibility_Registry_getDesktopCount (cspi_registry (), cspi_ev ()); } /** @@ -148,7 +196,9 @@ getDesktopCount () Accessible* getDesktop (int i) { - return Obj_Add (Accessibility_Registry_getDesktop (registry, (CORBA_short) i, &ev)); + return cspi_object_add (Accessibility_Registry_getDesktop (cspi_registry (), + (CORBA_short) i, + cspi_ev ())); } /** @@ -173,6 +223,7 @@ getDesktopList (Accessible **list) return 0; } +#if 0 static gboolean key_event_source_func (void *p) { @@ -192,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 @@ -211,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 @@ -225,25 +277,62 @@ registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, Accessibility_ControllerEventMask *controller_event_mask = Accessibility_ControllerEventMask__alloc(); Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (registry, &ev); - Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc(); + 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_DeviceEventController_ref (device_event_controller, &ev); + Accessibility_KeystrokeListener cspi_listener_corba_ref; + gint i, mask; + Accessibility_DeviceEventController_ref (device_event_controller, cspi_ev ()); + + /* copy the keyval filter values from the C api into the CORBA KeySet */ + if (keys) + { + key_set->_buffer = Accessibility_KeySet_allocbuf ( + (unsigned long) keys->len); + key_set->_length = (unsigned long) keys->len; + for (i=0; i < key_set->_length; ++i) + { + /* we overload the keyset long w/keycodes, the - bit acts as a flag */ + key_set->_buffer[i] = (keys->keysyms[i]) ? keys->keysyms[i] : + -keys->keycodes[i]; + /* g_print ("key-set %d = %d\n", i, (int) key_set->_buffer[i]); */ + } + } + /* copy the event filter values from the C api into the CORBA KeyEventTypeSeq */ + mask=1; + i=0; + do + { + if (mask & eventmask) ++i; + mask <<= 1; + } while (mask & 0xFFFF); + + key_events->_buffer = Accessibility_KeyEventTypeSeq_allocbuf (i); + i=0; + if (eventmask & SPI_KEY_PRESSED) + { + key_events->_buffer[i++] = Accessibility_KEY_PRESSED; + } + if (eventmask & SPI_KEY_RELEASED) + { + key_events->_buffer[i++] = Accessibility_KEY_RELEASED; + } + key_events->_length = i; + 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)), &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, - all_keys, + cspi_listener_corba_ref, + key_set, controller_event_mask, key_events, - (CORBA_boolean) ((sync_type | SPI_KEYLISTENER_ALL_WINDOWS)!=0), - &ev); + (CORBA_boolean) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0), + cspi_ev ()); } /** @@ -263,25 +352,25 @@ deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener, Accessibility_ControllerEventMask *controller_event_mask = Accessibility_ControllerEventMask__alloc(); Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (registry, &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, &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)), &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, - &ev); + cspi_ev ()); } /** @@ -290,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 @@ -304,11 +393,11 @@ generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type) * send keycode to alter, if necessary */ Accessibility_DeviceEventController device_event_controller = - Accessibility_Registry_getDeviceEventController (registry, &ev); + Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ()); Accessibility_DeviceEventController_generateKeyEvent (device_event_controller, keyval, (unsigned long) synth_type, - &ev); + cspi_ev ()); } /**