X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cspi%2Fspi_registry.c;h=cd7bdbc33af21d4fdc5a2a8813cc4cf8ea796782;hb=a31b958e89b901eec190109be30183a8afc6989d;hp=40f81b77734f0ff9a18ff42a6abdee275756b8bf;hpb=783e63cad5945ddb6df3ee129d20d5b53c6cce04;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/cspi/spi_registry.c b/cspi/spi_registry.c index 40f81b7..cd7bdbc 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: @@ -66,25 +91,22 @@ static Display *display = NULL; * Returns: #TRUE if successful, otherwise #FALSE. * **/ -boolean +SPIBoolean registerGlobalEventListener (AccessibleEventListener *listener, char *eventType) { + SPIBoolean 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; } /** @@ -93,30 +115,29 @@ 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. * **/ -boolean +SPIBoolean 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: @@ -130,26 +151,19 @@ deregisterGlobalEventListenerAll (AccessibleEventListener *listener) * Returns: #TRUE if successful, otherwise #FALSE. * **/ -boolean +SPIBoolean 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 (); } /** @@ -165,7 +179,7 @@ deregisterGlobalEventListener (AccessibleEventListener *listener, int getDesktopCount () { - return Accessibility_Registry_getDesktopCount (registry, &ev); + return Accessibility_Registry_getDesktopCount (cspi_registry (), cspi_ev ()); } /** @@ -182,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 ())); } /** @@ -207,32 +223,12 @@ getDesktopList (Accessible **list) return 0; } -static gboolean -key_event_source_func (void *p) -{ - GList *listeners = (GList *)p; - XEvent *x_event = g_new0 (XEvent, 1); - while (XPending (display)) - { - XNextEvent (display, x_event); - while (listeners) - { - /* if the listener mask matches, notify it*/ - if (1) - { - ; - } - } - } - return TRUE; -} - /** * 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 @@ -245,8 +241,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 @@ -259,25 +255,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 ()); } /** @@ -297,25 +330,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 ()); } /** @@ -324,7 +357,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 @@ -338,11 +371,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 ()); } /**