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 #SpiAccessibleEventListener to be registered against an event type.
15 * @callback: a character string indicating the type of events for which
16 * notification is requested. Format is
17 * EventClass:major_type:minor_type:detail
18 * where all subfields other than EventClass are optional.
19 * EventClasses include "Focus", "Window", "Mouse",
20 * and toolkit events (e.g. "Gtk", "AWT").
21 * Examples: "focus:", "Gtk:GtkWidget:button_press_event".
23 * NOTE: this string may be UTF-8, but should not contain byte value 56 (ascii ':'),
24 * except as a delimiter, since non-UTF-8 string delimiting
25 * functions are used internally. In general, listening to
26 * toolkit-specific events is not recommended.
28 * Add an in-process callback function to an existing SpiAccessibleEventListener.
30 * Returns: #TRUE if successful, otherwise #FALSE.
34 registerGlobalEventListener (SpiAccessibleEventListener *listener,
37 Accessibility_SpiRegistry_registerGlobalEventListener (
39 (Accessibility_EventListener)
40 bonobo_object_corba_objref (bonobo_object (listener)),
44 if (ev._major != CORBA_NO_EXCEPTION)
55 * deregisterGlobalEventListener:
56 * @listener: the #SpiAccessibleEventListener to be registered against an event type.
58 * deregisters an SpiAccessibleEventListener from the registry, for all event types it may be listening to.
60 * Returns: #TRUE if successful, otherwise #FALSE.
64 deregisterGlobalEventListenerAll (SpiAccessibleEventListener *listener)
66 Accessibility_SpiRegistry_deregisterGlobalEventListenerAll (
68 (Accessibility_EventListener)
69 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev),
72 if (ev._major != CORBA_NO_EXCEPTION)
85 * Get the number of virtual desktops.
86 * NOTE: currently multiple virtual desktops are not implemented, this
87 * function always returns '1'.
89 * Returns: an integer indicating the number of active virtual desktops.
95 return Accessibility_SpiRegistry_getDesktopCount (registry, &ev);
100 * @i: an integer indicating which of the accessible desktops is to be returned.
102 * Get the virtual desktop indicated by index @i.
103 * NOTE: currently multiple virtual desktops are not implemented, this
104 * function always returns '1'.
106 * Returns: a pointer to the 'i-th' virtual desktop's #SpiAccessible representation.
112 return Obj_Add (Accessibility_SpiRegistry_getDesktop (registry, (CORBA_short) n, &ev));
117 * @list: a pointer to an array of #SpiAccessible objects.
119 * Get the list of virtual desktops. On return, @list will point
120 * to a newly-created array of virtual desktop pointers.
121 * It is the responsibility of the caller to free this array when
122 * it is no longer needed.
124 * Not Yet Implemented.
126 * Returns: an integer indicating how many virtual desktops have been
127 * placed in the list pointed to by parameter @list.
130 getDesktopList (SpiAccessible **list)
137 key_event_source_func (void *p)
139 GList *listeners = (GList *)p;
140 XEvent *x_event = g_new0 (XEvent, 1);
141 while (XPending (display))
143 XNextEvent (display, x_event);
146 /* if the listener mask matches, notify it*/
157 save_this_impl_registerKeystrokeListener (KeystrokeListener *listener, KeyMaskType keymask)
159 static gboolean initialized = FALSE;
160 static Window grab_window;
161 XEvent *x_event = g_new0(XEvent, 1);
162 key_listeners = g_list_append (key_listeners, listener);
165 g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 200, key_event_source_func, key_listeners, NULL);
166 display = XOpenDisplay (getenv ("DISPLAY"));
167 grab_window = DefaultRootWindow (display);
168 XSelectInput (display, grab_window, KeyPress | KeyRelease);
181 XNextEvent (display, x_event);
187 * registerKeystrokeListener:
188 * @listener: a pointer to the #KeystrokeListener for which
189 * keystroke events are requested.
193 registerKeystrokeListener (KeystrokeListener *listener,
196 KeyEventMask eventmask,
197 KeySpiListenerSyncType sync_type)
199 Accessibility_ControllerEventMask *controller_event_mask =
200 Accessibility_ControllerEventMask__alloc();
201 Accessibility_SpiDeviceEventController device_event_controller =
202 Accessibility_SpiRegistry_getDeviceEventController (registry, &ev);
203 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
204 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
205 Accessibility_KeystrokeListener spi_listener_corba_ref;
206 Accessibility_SpiDeviceEventController_ref (device_event_controller, &ev);
207 controller_event_mask->value = (CORBA_unsigned_long) modmask;
208 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
210 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
211 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
213 Accessibility_SpiDeviceEventController_registerKeystrokeListener (
214 device_event_controller,
215 spi_listener_corba_ref,
217 controller_event_mask,
219 (CORBA_boolean) ((sync_type | KEYSPI_LISTENER_CANCONSUME)!=0),
224 * deregisterKeystrokeListener:
225 * @listener: a pointer to the #KeystrokeListener for which
226 * keystroke events are requested.
230 deregisterKeystrokeListener (KeystrokeListener *listener, KeyMaskType keymask)
232 Accessibility_ControllerEventMask *controller_event_mask =
233 Accessibility_ControllerEventMask__alloc();
234 Accessibility_SpiDeviceEventController device_event_controller =
235 Accessibility_SpiRegistry_getDeviceEventController (registry, &ev);
236 Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
237 Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
238 Accessibility_KeystrokeListener spi_listener_corba_ref;
239 Accessibility_SpiDeviceEventController_unref (device_event_controller, &ev);
240 controller_event_mask->value = (CORBA_unsigned_long) keymask;
241 controller_event_mask->refcount = (CORBA_unsigned_short) 1;
243 spi_listener_corba_ref = (Accessibility_KeystrokeListener)
244 CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
246 Accessibility_SpiDeviceEventController_deregisterKeystrokeListener (
247 device_event_controller,
248 spi_listener_corba_ref,
250 controller_event_mask,
252 (CORBA_boolean) TRUE,
258 * @keycode: a #long indicating the keycode of the key event
260 * @meta: a #long indicating the key modifiers to be sent
261 * with the event, if any.
263 * Synthesize a keyboard event (as if a hardware keyboard event occurred in the
264 * current UI context).
265 * Not Yet Implemented.
269 generateKeyEvent (long keyval, KeySynthType type)
271 /* TODO: check current modifier status and
272 * send keycode to alter, if necessary
274 Accessibility_SpiDeviceEventController device_event_controller =
275 Accessibility_SpiRegistry_getDeviceEventController (registry, &ev);
276 Accessibility_SpiDeviceEventController_generateKeyEvent (device_event_controller,
278 (unsigned long) type,
283 * generateMouseEvent:
284 * @x: a #long indicating the screen x coordinate of the mouse event.
285 * @y: a #long indicating the screen y coordinate of the mouse event.
286 * @name: a string indicating which mouse event to be synthesized
287 * (e.g. "button1", "button2", "mousemove").
289 * Synthesize a mouse event at a specific screen coordinate.
290 * Not Yet Implemented.
294 generateMouseEvent (long x, long y, char *name)