4 * Global functions serviced by the registry
8 /* static stuff used only by registry C bindings */
9 static GList *key_listeners = NULL;
10 static Display *display = NULL;
13 * registerGlobalEventListener:
14 * @listener: the #AccessibleEventListener to be registered against an
16 * @eventType: a character string indicating the type of events for which
17 * notification is requested. Format is
18 * EventClass:major_type:minor_type:detail
19 * where all subfields other than EventClass are optional.
20 * EventClasses include "Focus", "Window", "Mouse",
21 * and toolkit events (e.g. "Gtk", "AWT").
22 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
24 * NOTE: this string may be UTF-8, but should not contain byte value 56
25 * (ascii ':'), except as a delimiter, since non-UTF-8 string
26 * delimiting functions are used internally.
27 * In general, listening to
28 * toolkit-specific events is not recommended.
30 * Add an in-process callback function to an existing AccessibleEventListener.
32 * Returns: #TRUE if successful, otherwise #FALSE.
36 registerGlobalEventListener (AccessibleEventListener *listener,
39 Accessibility_Registry_registerGlobalEventListener (
41 (Accessibility_EventListener)
42 bonobo_object_corba_objref (bonobo_object (listener)),
46 if (ev._major != CORBA_NO_EXCEPTION)
57 * deregisterGlobalEventListenerAll:
58 * @listener: the #AccessibleEventListener to be registered against
61 * deregisters an AccessibleEventListener from the registry, for all
62 * event types it may be listening to.
64 * Returns: #TRUE if successful, otherwise #FALSE.
68 deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
70 Accessibility_Registry_deregisterGlobalEventListenerAll (
72 (Accessibility_EventListener)
73 CORBA_Object_duplicate (
74 bonobo_object_corba_objref (
75 bonobo_object (listener)), &ev),
78 if (ev._major != CORBA_NO_EXCEPTION)
88 * deregisterGlobalEventListener:
89 * @listener: the #AccessibleEventListener registered against an event type.
90 * @eventType: a string specifying the event type for which this
91 * listener is to be deregistered.
93 * deregisters an AccessibleEventListener from the registry, for a specific
96 * Returns: #TRUE if successful, otherwise #FALSE.
100 deregisterGlobalEventListener (AccessibleEventListener *listener,
103 Accessibility_Registry_deregisterGlobalEventListener (
105 (Accessibility_EventListener)
106 CORBA_Object_duplicate (
107 bonobo_object_corba_objref (bonobo_object (listener)), &ev),
108 (CORBA_char *) eventType,
111 if (ev._major != CORBA_NO_EXCEPTION)
124 * Get the number of virtual desktops.
125 * NOTE: currently multiple virtual desktops are not implemented, this
126 * function always returns '1'.
128 * Returns: an integer indicating the number of active virtual desktops.
134 return Accessibility_Registry_getDesktopCount (registry, &ev);
139 * @i: an integer indicating which of the accessible desktops is to be returned.
141 * Get the virtual desktop indicated by index @i.
142 * NOTE: currently multiple virtual desktops are not implemented, this
143 * function always returns '1'.
145 * Returns: a pointer to the 'i-th' virtual desktop's #Accessible representation.
151 return Obj_Add (Accessibility_Registry_getDesktop (registry, (CORBA_short) i, &ev));
156 * @list: a pointer to an array of #Accessible objects.
158 * Get the list of virtual desktops. On return, @list will point
159 * to a newly-created array of virtual desktop pointers.
160 * It is the responsibility of the caller to free this array when
161 * it is no longer needed.
163 * Not Yet Implemented : this implementation always returns a single
164 * #Accessible desktop.
166 * Returns: an integer indicating how many virtual desktops have been
167 * placed in the list pointed to by parameter @list.
170 getDesktopList (Accessible **list)
177 key_event_source_func (void *p)
179 GList *listeners = (GList *)p;
180 XEvent *x_event = g_new0 (XEvent, 1);
181 while (XPending (display))
183 XNextEvent (display, x_event);
186 /* if the listener mask matches, notify it*/
197 * registerAccessibleKeystrokeListener:
198 * @listener: a pointer to the #AccessibleKeystrokeListener for which
199 * keystroke events are requested.
200 * @keys: a pointer to the #AccessibleKeySet indicating which
201 * keystroke events are requested, or #SPI_KEYSET_ALL_KEYS.
202 * @modmask: an #AccessibleKeyMaskType mask indicating which
203 * key event modifiers must be set in combination with @keys,
204 * events will only be reported for key events for which all
205 * modifiers in @modmask are set. If you wish to listen for
206 * events with multiple modifier combinations you must call
207 * registerAccessibleKeystrokeListener() once for each combination.
208 * @eventmask: an #AccessibleKeyMaskType mask indicating which
209 * types of key events are requested (#SPI_KEY_PRESSED, etc.).
210 * @sync_type: a #AccessibleKeyListenerSyncType parameter indicating
211 * the behavior of the notification/listener transaction.
213 * Register a listener for keystroke events, either pre-emptively for
214 * all windows (SPI_KEYLISTENER_ALL_WINDOWS), or
215 * non-preemptively (SPI_KEYLISTENER_NOSYNC).
216 * ( Other sync_type values may be available in the future.)
219 registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
220 AccessibleKeySet *keys,
221 AccessibleKeyMaskType modmask,
222 AccessibleKeyEventMask eventmask,
223 AccessibleKeyListenerSyncType sync_type)
225 Accessibility_ControllerEventMask *controller_event_mask =
226 Accessibility_ControllerEventMask__alloc();
227 Accessibility_DeviceEventController device_event_controller =
228 Accessibility_Registry_getDeviceEventController (registry, &ev);
229 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
230 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
231 Accessibility_KeystrokeListener spi_listener_corba_ref;
232 Accessibility_DeviceEventController_ref (device_event_controller, &ev);
233 controller_event_mask->value = (CORBA_unsigned_long) modmask;
234 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
236 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
237 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
239 Accessibility_DeviceEventController_registerKeystrokeListener (
240 device_event_controller,
241 spi_listener_corba_ref,
243 controller_event_mask,
245 (CORBA_boolean) ((sync_type | SPI_KEYLISTENER_ALL_WINDOWS)!=0),
250 * deregisterAccessibleKeystrokeListener:
251 * @listener: a pointer to the #AccessibleKeystrokeListener for which
252 * keystroke events are requested.
253 * @modmask: the key modifier mask for which this listener is to be
254 * 'deregistered' (of type #AccessibleeyMaskType).
256 * Removes a keystroke event listener from the registry's listener queue,
257 * ceasing notification of events with modifiers matching @modmask.
260 deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
261 AccessibleKeyMaskType modmask)
263 Accessibility_ControllerEventMask *controller_event_mask =
264 Accessibility_ControllerEventMask__alloc();
265 Accessibility_DeviceEventController device_event_controller =
266 Accessibility_Registry_getDeviceEventController (registry, &ev);
267 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
268 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
269 Accessibility_KeystrokeListener spi_listener_corba_ref;
270 Accessibility_DeviceEventController_unref (device_event_controller, &ev);
271 controller_event_mask->value = (CORBA_unsigned_long) modmask;
272 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
274 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
275 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
277 Accessibility_DeviceEventController_deregisterKeystrokeListener (
278 device_event_controller,
279 spi_listener_corba_ref,
281 controller_event_mask,
283 (CORBA_boolean) TRUE,
289 * @keyval: a long integer indicating the keycode or keysym of the key event
291 * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
292 * is to be interpreted as a keysym rather than a keycode
293 * (SPI_KEYSYM), or whether to synthesize
294 * SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
296 * Synthesize a keyboard event (as if a hardware keyboard event occurred in the
297 * current UI context).
301 generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type)
303 /* TODO: check current modifier status and
304 * send keycode to alter, if necessary
306 Accessibility_DeviceEventController device_event_controller =
307 Accessibility_Registry_getDeviceEventController (registry, &ev);
308 Accessibility_DeviceEventController_generateKeyEvent (device_event_controller,
310 (unsigned long) synth_type,
315 * generateMouseEvent:
316 * @x: a #long indicating the screen x coordinate of the mouse event.
317 * @y: a #long indicating the screen y coordinate of the mouse event.
318 * @name: a string indicating which mouse event to be synthesized
319 * (e.g. "button1", "button2", "mousemove").
321 * Synthesize a mouse event at a specific screen coordinate.
322 * Most AT clients should use the #AccessibleAction interface when
323 * tempted to generate mouse events, rather than this method.
324 * Not Yet Implemented.
328 generateMouseEvent (long x, long y, char *name)