2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* spi_registry.c: Global functions wrapping the registry */
25 #include <cspi/spi-private.h>
28 * registerGlobalEventListener:
29 * @listener: the #AccessibleEventListener to be registered against an
31 * @eventType: a character string indicating the type of events for which
32 * notification is requested. Format is
33 * EventClass:major_type:minor_type:detail
34 * where all subfields other than EventClass are optional.
35 * EventClasses include "object", "window", "mouse",
36 * and toolkit events (e.g. "Gtk", "AWT").
37 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
39 * Legal object event types:
41 * (property change events)
43 * object:property-change
44 * object:property-change:accessible-name
45 * object:property-change:accessible-state
46 * object:property-change:accessible-description
47 * object:property-change:accessible-parent
48 * object:property-change:accessible-value
49 * object:property-change:accessible-role
50 * object:property-change:accessible-table-caption
51 * object:property-change:accessible-table-column-description
52 * object:property-change:accessible-table-column-header
53 * object:property-change:accessible-table-row-description
54 * object:property-change:accessible-table-row-header
55 * object:property-change:accessible-table-summary
57 * (other object events)
59 * object:children-changed
60 * object:visible-data-changed
61 * object:selection-changed
62 * object:text-selection-changed
64 * object:text-caret-moved
66 * object:row-reordered
68 * object:column-inserted
69 * object:column-reordered
70 * object:column-deleted
71 * object:model-changed
73 * NOTE: this string may be UTF-8, but should not contain byte value 56
74 * (ascii ':'), except as a delimiter, since non-UTF-8 string
75 * delimiting functions are used internally.
76 * In general, listening to
77 * toolkit-specific events is not recommended.
79 * Add an in-process callback function to an existing AccessibleEventListener.
81 * Returns: #TRUE if successful, otherwise #FALSE.
85 registerGlobalEventListener (AccessibleEventListener *listener,
86 const char *eventType)
90 Accessibility_Registry_registerGlobalEventListener (
92 (Accessibility_EventListener)
93 BONOBO_OBJREF (bonobo_object (listener)),
97 retval = !cspi_exception ();
103 * deregisterGlobalEventListenerAll:
104 * @listener: the #AccessibleEventListener to be registered against
107 * deregisters an AccessibleEventListener from the registry, for all
108 * event types it may be listening to. Use
109 * AccessibleEventListener_unref to release the
110 * listener reference.
112 * Returns: #TRUE if successful, otherwise #FALSE.
116 deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
118 Accessibility_Registry_deregisterGlobalEventListenerAll (
120 (Accessibility_EventListener) BONOBO_OBJREF (listener),
123 return !cspi_exception ();
126 * deregisterGlobalEventListener:
127 * @listener: the #AccessibleEventListener registered against an event type.
128 * @eventType: a string specifying the event type for which this
129 * listener is to be deregistered.
131 * deregisters an AccessibleEventListener from the registry, for a specific
134 * Returns: #TRUE if successful, otherwise #FALSE.
138 deregisterGlobalEventListener (AccessibleEventListener *listener,
139 const char *eventType)
141 Accessibility_Registry_deregisterGlobalEventListener (
143 (Accessibility_EventListener) BONOBO_OBJREF (listener),
144 (CORBA_char *) eventType,
147 return !cspi_exception ();
153 * Get the number of virtual desktops.
154 * NOTE: currently multiple virtual desktops are not implemented, this
155 * function always returns '1'.
157 * Returns: an integer indicating the number of active virtual desktops.
163 return Accessibility_Registry_getDesktopCount (cspi_registry (), cspi_ev ());
168 * @i: an integer indicating which of the accessible desktops is to be returned.
170 * Get the virtual desktop indicated by index @i.
171 * NOTE: currently multiple virtual desktops are not implemented, this
172 * function always returns '1'.
174 * Returns: a pointer to the 'i-th' virtual desktop's #Accessible representation.
180 return cspi_object_add_check (Accessibility_Registry_getDesktop (cspi_registry (),
187 * @list: a pointer to an array of #Accessible objects.
189 * Get the list of virtual desktops. On return, @list will point
190 * to a newly-created array of virtual desktop pointers.
191 * It is the responsibility of the caller to free this array when
192 * it is no longer needed.
194 * Not Yet Implemented : this implementation always returns a single
195 * #Accessible desktop.
197 * Returns: an integer indicating how many virtual desktops have been
198 * placed in the list pointed to by parameter @list.
201 getDesktopList (Accessible **list)
208 * registerAccessibleKeystrokeListener:
209 * @listener: a pointer to the #AccessibleKeystrokeListener for which
210 * keystroke events are requested.
211 * @keys: a pointer to the #AccessibleKeySet indicating which
212 * keystroke events are requested, or #CSPI_KEYSET_ALL_KEYS.
213 * @modmask: an #AccessibleKeyMaskType mask indicating which
214 * key event modifiers must be set in combination with @keys,
215 * events will only be reported for key events for which all
216 * modifiers in @modmask are set. If you wish to listen for
217 * events with multiple modifier combinations you must call
218 * registerAccessibleKeystrokeListener() once for each combination.
219 * @eventmask: an #AccessibleKeyMaskType mask indicating which
220 * types of key events are requested (#SPI_KEY_PRESSED, etc.).
221 * @sync_type: a #AccessibleKeyListenerSyncType parameter indicating
222 * the behavior of the notification/listener transaction.
224 * Register a listener for keystroke events, either pre-emptively for
225 * all windows (CSPI_KEYLISTENER_ALL_WINDOWS), or
226 * non-preemptively (CSPI_KEYLISTENER_NOSYNC).
227 * ( Other sync_type values may be available in the future.)
230 registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
231 AccessibleKeySet *keys,
232 AccessibleKeyMaskType modmask,
233 AccessibleKeyEventMask eventmask,
234 AccessibleKeyListenerSyncType sync_type)
237 Accessibility_KeySet key_set;
238 Accessibility_KeyEventTypeSeq key_events;
239 Accessibility_ControllerEventMask controller_event_mask;
240 Accessibility_DeviceEventController device_event_controller;
242 device_event_controller =
243 Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
245 g_return_if_fail (cspi_warn_ev (cspi_ev (), "getting event controller"));
247 /* copy the keyval filter values from the C api into the CORBA KeySet */
250 key_set._length = keys->len;
251 key_set._buffer = Accessibility_KeySet_allocbuf (keys->len);
252 for (i = 0; i < key_set._length; ++i)
254 /* we overload the keyset long w/keycodes, the - bit acts as a flag */
255 key_set._buffer[i] = (keys->keysyms[i]) ? keys->keysyms[i] :
257 /* g_print ("key-set %d = %d\n", i, (int) key_set->_buffer[i]); */
263 key_set._buffer = NULL;
266 /* copy the event filter values from the C api into the CORBA KeyEventTypeSeq */
271 if (mask & eventmask)
277 while (mask & 0xFFFF);
279 key_events._buffer = Accessibility_KeyEventTypeSeq_allocbuf (i);
281 if (eventmask & SPI_KEY_PRESSED)
283 key_events._buffer[i++] = Accessibility_KEY_PRESSED;
285 if (eventmask & SPI_KEY_RELEASED)
287 key_events._buffer[i++] = Accessibility_KEY_RELEASED;
289 key_events._length = i;
291 controller_event_mask.value = (CORBA_unsigned_long) modmask;
292 controller_event_mask.refcount = (CORBA_unsigned_short) 1;
294 Accessibility_DeviceEventController_registerKeystrokeListener (
295 device_event_controller,
296 BONOBO_OBJREF (listener),
298 &controller_event_mask,
300 (CORBA_boolean) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0),
303 bonobo_object_release_unref (device_event_controller, cspi_ev ());
307 * deregisterAccessibleKeystrokeListener:
308 * @listener: a pointer to the #AccessibleKeystrokeListener for which
309 * keystroke events are requested.
310 * @modmask: the key modifier mask for which this listener is to be
311 * 'deregistered' (of type #AccessibleeyMaskType).
313 * Removes a keystroke event listener from the registry's listener queue,
314 * ceasing notification of events with modifiers matching @modmask.
317 deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
318 AccessibleKeyMaskType modmask)
320 Accessibility_ControllerEventMask controller_event_mask;
321 Accessibility_KeySet key_set;
322 Accessibility_KeyEventTypeSeq key_events;
323 Accessibility_DeviceEventController device_event_controller;
325 device_event_controller =
326 Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
328 g_return_if_fail (cspi_warn_ev (cspi_ev (), "getting event controller"));
330 controller_event_mask.value = (CORBA_unsigned_long) modmask;
331 controller_event_mask.refcount = (CORBA_unsigned_short) 1;
333 key_events._buffer = NULL;
334 key_events._length = 0;
336 key_set._buffer = NULL;
339 Accessibility_DeviceEventController_deregisterKeystrokeListener (
340 device_event_controller,
341 BONOBO_OBJREF (listener),
343 &controller_event_mask,
345 (CORBA_boolean) TRUE,
348 bonobo_object_release_unref (device_event_controller, NULL);
353 * @keyval: a long integer indicating the keycode or keysym of the key event
355 * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
356 * is to be interpreted as a keysym rather than a keycode
357 * (CSPI_KEYSYM), or whether to synthesize
358 * SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
360 * Synthesize a keyboard event (as if a hardware keyboard event occurred in the
361 * current UI context).
365 generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type)
367 /* TODO: check current modifier status and
368 * send keycode to alter, if necessary
370 Accessibility_DeviceEventController device_event_controller =
371 Accessibility_Registry_getDeviceEventController (cspi_registry (), cspi_ev ());
373 g_return_if_fail (cspi_warn_ev (cspi_ev (), "getting event controller"));
375 Accessibility_DeviceEventController_generateKeyEvent (device_event_controller,
377 (unsigned long) synth_type,
380 bonobo_object_release_unref (device_event_controller, NULL);
384 * generateMouseEvent:
385 * @x: a #long indicating the screen x coordinate of the mouse event.
386 * @y: a #long indicating the screen y coordinate of the mouse event.
387 * @name: a string indicating which mouse event to be synthesized
388 * (e.g. "button1", "button2", "mousemove").
390 * Synthesize a mouse event at a specific screen coordinate.
391 * Most AT clients should use the #AccessibleAction interface when
392 * tempted to generate mouse events, rather than this method.
393 * Not Yet Implemented.
397 generateMouseEvent (long x, long y, char *name)