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.
25 * Global functions serviced by the registry
29 /* static stuff used only by registry C bindings */
30 static GList *key_listeners = NULL;
31 static Display *display = NULL;
34 * registerGlobalEventListener:
35 * @listener: the #AccessibleEventListener to be registered against an
37 * @eventType: a character string indicating the type of events for which
38 * notification is requested. Format is
39 * EventClass:major_type:minor_type:detail
40 * where all subfields other than EventClass are optional.
41 * EventClasses include "object", "window", "mouse",
42 * and toolkit events (e.g. "Gtk", "AWT").
43 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
45 * Legal object event types:
47 * (property change events)
49 * object:property-change
50 * object:property-change:accessible-name
51 * object:property-change:accessible-state
52 * object:property-change:accessible-description
53 * object:property-change:accessible-parent
54 * object:property-change:accessible-value
55 * object:property-change:accessible-role
56 * object:property-change:accessible-table-caption
57 * object:property-change:accessible-table-column-description
58 * object:property-change:accessible-table-column-header
59 * object:property-change:accessible-table-row-description
60 * object:property-change:accessible-table-row-header
61 * object:property-change:accessible-table-summary
63 * (other object events)
65 * object:children-changed
66 * object:visible-data-changed
67 * object:selection-changed
68 * object:text-selection-changed
70 * object:text-caret-moved
72 * object:row-reordered
74 * object:column-inserted
75 * object:column-reordered
76 * object:column-deleted
77 * object:model-changed
79 * NOTE: this string may be UTF-8, but should not contain byte value 56
80 * (ascii ':'), except as a delimiter, since non-UTF-8 string
81 * delimiting functions are used internally.
82 * In general, listening to
83 * toolkit-specific events is not recommended.
85 * Add an in-process callback function to an existing AccessibleEventListener.
87 * Returns: #TRUE if successful, otherwise #FALSE.
91 registerGlobalEventListener (AccessibleEventListener *listener,
94 Accessibility_Registry_registerGlobalEventListener (
96 (Accessibility_EventListener)
97 bonobo_object_corba_objref (bonobo_object (listener)),
101 if (ev._major != CORBA_NO_EXCEPTION)
112 * deregisterGlobalEventListenerAll:
113 * @listener: the #AccessibleEventListener to be registered against
116 * deregisters an AccessibleEventListener from the registry, for all
117 * event types it may be listening to.
119 * Returns: #TRUE if successful, otherwise #FALSE.
123 deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
125 Accessibility_Registry_deregisterGlobalEventListenerAll (
127 (Accessibility_EventListener)
128 CORBA_Object_duplicate (
129 bonobo_object_corba_objref (
130 bonobo_object (listener)), &ev),
133 if (ev._major != CORBA_NO_EXCEPTION)
143 * deregisterGlobalEventListener:
144 * @listener: the #AccessibleEventListener registered against an event type.
145 * @eventType: a string specifying the event type for which this
146 * listener is to be deregistered.
148 * deregisters an AccessibleEventListener from the registry, for a specific
151 * Returns: #TRUE if successful, otherwise #FALSE.
155 deregisterGlobalEventListener (AccessibleEventListener *listener,
158 Accessibility_Registry_deregisterGlobalEventListener (
160 (Accessibility_EventListener)
161 CORBA_Object_duplicate (
162 bonobo_object_corba_objref (bonobo_object (listener)), &ev),
163 (CORBA_char *) eventType,
166 if (ev._major != CORBA_NO_EXCEPTION)
179 * Get the number of virtual desktops.
180 * NOTE: currently multiple virtual desktops are not implemented, this
181 * function always returns '1'.
183 * Returns: an integer indicating the number of active virtual desktops.
189 return Accessibility_Registry_getDesktopCount (registry, &ev);
194 * @i: an integer indicating which of the accessible desktops is to be returned.
196 * Get the virtual desktop indicated by index @i.
197 * NOTE: currently multiple virtual desktops are not implemented, this
198 * function always returns '1'.
200 * Returns: a pointer to the 'i-th' virtual desktop's #Accessible representation.
206 return Obj_Add (Accessibility_Registry_getDesktop (registry, (CORBA_short) i, &ev));
211 * @list: a pointer to an array of #Accessible objects.
213 * Get the list of virtual desktops. On return, @list will point
214 * to a newly-created array of virtual desktop pointers.
215 * It is the responsibility of the caller to free this array when
216 * it is no longer needed.
218 * Not Yet Implemented : this implementation always returns a single
219 * #Accessible desktop.
221 * Returns: an integer indicating how many virtual desktops have been
222 * placed in the list pointed to by parameter @list.
225 getDesktopList (Accessible **list)
232 key_event_source_func (void *p)
234 GList *listeners = (GList *)p;
235 XEvent *x_event = g_new0 (XEvent, 1);
236 while (XPending (display))
238 XNextEvent (display, x_event);
241 /* if the listener mask matches, notify it*/
252 * registerAccessibleKeystrokeListener:
253 * @listener: a pointer to the #AccessibleKeystrokeListener for which
254 * keystroke events are requested.
255 * @keys: a pointer to the #AccessibleKeySet indicating which
256 * keystroke events are requested, or #SPI_KEYSET_ALL_KEYS.
257 * @modmask: an #AccessibleKeyMaskType mask indicating which
258 * key event modifiers must be set in combination with @keys,
259 * events will only be reported for key events for which all
260 * modifiers in @modmask are set. If you wish to listen for
261 * events with multiple modifier combinations you must call
262 * registerAccessibleKeystrokeListener() once for each combination.
263 * @eventmask: an #AccessibleKeyMaskType mask indicating which
264 * types of key events are requested (#SPI_KEY_PRESSED, etc.).
265 * @sync_type: a #AccessibleKeyListenerSyncType parameter indicating
266 * the behavior of the notification/listener transaction.
268 * Register a listener for keystroke events, either pre-emptively for
269 * all windows (SPI_KEYLISTENER_ALL_WINDOWS), or
270 * non-preemptively (SPI_KEYLISTENER_NOSYNC).
271 * ( Other sync_type values may be available in the future.)
274 registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
275 AccessibleKeySet *keys,
276 AccessibleKeyMaskType modmask,
277 AccessibleKeyEventMask eventmask,
278 AccessibleKeyListenerSyncType sync_type)
280 Accessibility_ControllerEventMask *controller_event_mask =
281 Accessibility_ControllerEventMask__alloc();
282 Accessibility_DeviceEventController device_event_controller =
283 Accessibility_Registry_getDeviceEventController (registry, &ev);
284 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
285 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
286 Accessibility_KeystrokeListener spi_listener_corba_ref;
287 Accessibility_DeviceEventController_ref (device_event_controller, &ev);
288 controller_event_mask->value = (CORBA_unsigned_long) modmask;
289 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
291 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
292 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
294 Accessibility_DeviceEventController_registerKeystrokeListener (
295 device_event_controller,
296 spi_listener_corba_ref,
298 controller_event_mask,
300 (CORBA_boolean) ((sync_type | SPI_KEYLISTENER_ALL_WINDOWS)!=0),
305 * deregisterAccessibleKeystrokeListener:
306 * @listener: a pointer to the #AccessibleKeystrokeListener for which
307 * keystroke events are requested.
308 * @modmask: the key modifier mask for which this listener is to be
309 * 'deregistered' (of type #AccessibleeyMaskType).
311 * Removes a keystroke event listener from the registry's listener queue,
312 * ceasing notification of events with modifiers matching @modmask.
315 deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
316 AccessibleKeyMaskType modmask)
318 Accessibility_ControllerEventMask *controller_event_mask =
319 Accessibility_ControllerEventMask__alloc();
320 Accessibility_DeviceEventController device_event_controller =
321 Accessibility_Registry_getDeviceEventController (registry, &ev);
322 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
323 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
324 Accessibility_KeystrokeListener spi_listener_corba_ref;
325 Accessibility_DeviceEventController_unref (device_event_controller, &ev);
326 controller_event_mask->value = (CORBA_unsigned_long) modmask;
327 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
329 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
330 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
332 Accessibility_DeviceEventController_deregisterKeystrokeListener (
333 device_event_controller,
334 spi_listener_corba_ref,
336 controller_event_mask,
338 (CORBA_boolean) TRUE,
344 * @keyval: a long integer indicating the keycode or keysym of the key event
346 * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
347 * is to be interpreted as a keysym rather than a keycode
348 * (SPI_KEYSYM), or whether to synthesize
349 * SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
351 * Synthesize a keyboard event (as if a hardware keyboard event occurred in the
352 * current UI context).
356 generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type)
358 /* TODO: check current modifier status and
359 * send keycode to alter, if necessary
361 Accessibility_DeviceEventController device_event_controller =
362 Accessibility_Registry_getDeviceEventController (registry, &ev);
363 Accessibility_DeviceEventController_generateKeyEvent (device_event_controller,
365 (unsigned long) synth_type,
370 * generateMouseEvent:
371 * @x: a #long indicating the screen x coordinate of the mouse event.
372 * @y: a #long indicating the screen y coordinate of the mouse event.
373 * @name: a string indicating which mouse event to be synthesized
374 * (e.g. "button1", "button2", "mousemove").
376 * Synthesize a mouse event at a specific screen coordinate.
377 * Most AT clients should use the #AccessibleAction interface when
378 * tempted to generate mouse events, rather than this method.
379 * Not Yet Implemented.
383 generateMouseEvent (long x, long y, char *name)