+/*
+ * 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.
+ */
/*
*
/**
* registerGlobalEventListener:
- * @listener: the #AccessibleEventListener to be registered against an event type.
- * @callback: a character string indicating the type of events for which
+ * @listener: the #AccessibleEventListener to be registered against an
+ * event type.
+ * @eventType: a character string indicating the type of events for which
* notification is requested. Format is
* EventClass:major_type:minor_type:detail
* where all subfields other than EventClass are optional.
- * EventClasses include "Focus", "Window", "Mouse",
+ * EventClasses include "object", "window", "mouse",
* and toolkit events (e.g. "Gtk", "AWT").
* Examples: "focus:", "Gtk:GtkWidget:button_press_event".
*
- * NOTE: this string may be UTF-8, but should not contain byte value 56 (ascii ':'),
- * except as a delimiter, since non-UTF-8 string delimiting
- * functions are used internally. In general, listening to
+ * Legal object event types:
+ *
+ * (property change events)
+ *
+ * object:property-change
+ * object:property-change:accessible-name
+ * object:property-change:accessible-state
+ * object:property-change:accessible-description
+ * object:property-change:accessible-parent
+ * object:property-change:accessible-value
+ * object:property-change:accessible-role
+ * object:property-change:accessible-table-caption
+ * object:property-change:accessible-table-column-description
+ * object:property-change:accessible-table-column-header
+ * object:property-change:accessible-table-row-description
+ * object:property-change:accessible-table-row-header
+ * object:property-change:accessible-table-summary
+ *
+ * (other object events)
+ *
+ * object:children-changed
+ * object:visible-data-changed
+ * object:selection-changed
+ * object:text-selection-changed
+ * object:text-changed
+ * object:text-caret-moved
+ * object:row-inserted
+ * object:row-reordered
+ * object:row-deleted
+ * object:column-inserted
+ * object:column-reordered
+ * object:column-deleted
+ * object:model-changed
+ *
+ * NOTE: this string may be UTF-8, but should not contain byte value 56
+ * (ascii ':'), except as a delimiter, since non-UTF-8 string
+ * delimiting functions are used internally.
+ * In general, listening to
* toolkit-specific events is not recommended.
*
* Add an in-process callback function to an existing AccessibleEventListener.
}
/**
- * deregisterGlobalEventListener:
- * @listener: the #AccessibleEventListener to be registered against an event type.
+ * deregisterGlobalEventListenerAll:
+ * @listener: the #AccessibleEventListener to be registered against
+ * an event type.
*
- * deregisters an AccessibleEventListener from the registry, for all event types it may be listening to.
+ * deregisters an AccessibleEventListener from the registry, for all
+ * event types it may be listening to.
*
* Returns: #TRUE if successful, otherwise #FALSE.
*
Accessibility_Registry_deregisterGlobalEventListenerAll (
registry,
(Accessibility_EventListener)
- CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev),
+ CORBA_Object_duplicate (
+ bonobo_object_corba_objref (
+ bonobo_object (listener)), &ev),
&ev);
if (ev._major != CORBA_NO_EXCEPTION)
return TRUE;
}
}
+/**
+ * deregisterGlobalEventListener:
+ * @listener: the #AccessibleEventListener registered against an event type.
+ * @eventType: a string specifying the event type for which this
+ * listener is to be deregistered.
+ *
+ * deregisters an AccessibleEventListener from the registry, for a specific
+ * event type.
+ *
+ * Returns: #TRUE if successful, otherwise #FALSE.
+ *
+ **/
+boolean
+deregisterGlobalEventListener (AccessibleEventListener *listener,
+ char *eventType)
+{
+ Accessibility_Registry_deregisterGlobalEventListener (
+ registry,
+ (Accessibility_EventListener)
+ CORBA_Object_duplicate (
+ bonobo_object_corba_objref (bonobo_object (listener)), &ev),
+ (CORBA_char *) eventType,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
/**
* getDesktopCount:
*
**/
Accessible*
-getDesktop (int n)
+getDesktop (int i)
{
- return Obj_Add (Accessibility_Registry_getDesktop (registry, (CORBA_short) n, &ev));
+ return Obj_Add (Accessibility_Registry_getDesktop (registry, (CORBA_short) i, &ev));
}
/**
* It is the responsibility of the caller to free this array when
* it is no longer needed.
*
- * Not Yet Implemented.
+ * Not Yet Implemented : this implementation always returns a single
+ * #Accessible desktop.
*
* Returns: an integer indicating how many virtual desktops have been
* placed in the list pointed to by parameter @list.
return TRUE;
}
-void
-save_this_impl_registerKeystrokeListener (KeystrokeListener *listener, KeyMaskType keymask)
-{
- static gboolean initialized = FALSE;
- static Window grab_window;
- XEvent *x_event = g_new0(XEvent, 1);
- key_listeners = g_list_append (key_listeners, listener);
- if (!initialized)
- {
- g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 200, key_event_source_func, key_listeners, NULL);
- display = XOpenDisplay (getenv ("DISPLAY"));
- grab_window = DefaultRootWindow (display);
- XSelectInput (display, grab_window, KeyPress | KeyRelease);
- initialized = TRUE;
- }
- /* */
- XGrabKey (display,
- AnyKey,
- LockMask,
- grab_window,
- False,
- GrabModeAsync,
- GrabModeAsync);
- while (0)
- {
- XNextEvent (display, x_event);
- g_print ("foo!\n");
- }
-}
-
/**
- * registerKeystrokeListener:
- * @listener: a pointer to the #KeystrokeListener for which
- * keystroke events are requested.
- *
+ * 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.
+ * @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
+ * modifiers in @modmask are set. If you wish to listen for
+ * events with multiple modifier combinations you must call
+ * registerAccessibleKeystrokeListener() once for each combination.
+ * @eventmask: an #AccessibleKeyMaskType mask indicating which
+ * types of key events are requested (#SPI_KEY_PRESSED, etc.).
+ * @sync_type: a #AccessibleKeyListenerSyncType parameter indicating
+ * 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).
+ * ( Other sync_type values may be available in the future.)
**/
void
-registerKeystrokeListener (KeystrokeListener *listener,
- KeySet *keys,
- KeyMaskType modmask,
- KeyEventMask eventmask,
- KeyListenerSyncType sync_type)
+registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
+ AccessibleKeySet *keys,
+ AccessibleKeyMaskType modmask,
+ AccessibleKeyEventMask eventmask,
+ AccessibleKeyListenerSyncType sync_type)
{
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_KeySet *key_set = Accessibility_KeySet__alloc();
Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
- Accessibility_KeystrokeListener listener_corba_ref;
+ Accessibility_KeystrokeListener spi_listener_corba_ref;
+ gint i, mask;
Accessibility_DeviceEventController_ref (device_event_controller, &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];
+ }
+ }
+ /* 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;
- listener_corba_ref = (Accessibility_KeystrokeListener)
+ spi_listener_corba_ref = (Accessibility_KeystrokeListener)
CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
Accessibility_DeviceEventController_registerKeystrokeListener (
device_event_controller,
- listener_corba_ref,
- all_keys,
+ spi_listener_corba_ref,
+ key_set,
controller_event_mask,
key_events,
- (CORBA_boolean) ((sync_type | KEYLISTENER_CANCONSUME)!=0),
+ (CORBA_boolean) ((sync_type & SPI_KEYLISTENER_ALL_WINDOWS)!=0),
&ev);
}
/**
- * deregisterKeystrokeListener:
- * @listener: a pointer to the #KeystrokeListener for which
+ * deregisterAccessibleKeystrokeListener:
+ * @listener: a pointer to the #AccessibleKeystrokeListener for which
* keystroke events are requested.
+ * @modmask: the key modifier mask for which this listener is to be
+ * 'deregistered' (of type #AccessibleeyMaskType).
*
+ * Removes a keystroke event listener from the registry's listener queue,
+ * ceasing notification of events with modifiers matching @modmask.
**/
void
-deregisterKeystrokeListener (KeystrokeListener *listener, KeyMaskType keymask)
+deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
+ AccessibleKeyMaskType modmask)
{
Accessibility_ControllerEventMask *controller_event_mask =
Accessibility_ControllerEventMask__alloc();
Accessibility_Registry_getDeviceEventController (registry, &ev);
Accessibility_KeySet *all_keys = Accessibility_KeySet__alloc();
Accessibility_KeyEventTypeSeq *key_events = Accessibility_KeyEventTypeSeq__alloc();
- Accessibility_KeystrokeListener listener_corba_ref;
+ Accessibility_KeystrokeListener spi_listener_corba_ref;
Accessibility_DeviceEventController_unref (device_event_controller, &ev);
- controller_event_mask->value = (CORBA_unsigned_long) keymask;
+ controller_event_mask->value = (CORBA_unsigned_long) modmask;
controller_event_mask->refcount = (CORBA_unsigned_short) 1;
- listener_corba_ref = (Accessibility_KeystrokeListener)
+ spi_listener_corba_ref = (Accessibility_KeystrokeListener)
CORBA_Object_duplicate (bonobo_object_corba_objref (bonobo_object (listener)), &ev);
Accessibility_DeviceEventController_deregisterKeystrokeListener (
device_event_controller,
- listener_corba_ref,
+ spi_listener_corba_ref,
all_keys,
controller_event_mask,
key_events,
/**
* generateKeyEvent:
- * @keycode: a #long indicating the keycode of the key event
+ * @keyval: a long integer indicating the keycode or keysym of the key event
* being synthesized.
- * @meta: a #long indicating the key modifiers to be sent
- * with the event, if any.
+ * @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
+ * SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
*
* Synthesize a keyboard event (as if a hardware keyboard event occurred in the
* current UI context).
- * Not Yet Implemented.
*
**/
void
-generateKeyEvent (long keyCode, long meta)
+generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type)
{
- ;
+/* TODO: check current modifier status and
+ * send keycode to alter, if necessary
+ */
+ Accessibility_DeviceEventController device_event_controller =
+ Accessibility_Registry_getDeviceEventController (registry, &ev);
+ Accessibility_DeviceEventController_generateKeyEvent (device_event_controller,
+ keyval,
+ (unsigned long) synth_type,
+ &ev);
}
/**
* (e.g. "button1", "button2", "mousemove").
*
* Synthesize a mouse event at a specific screen coordinate.
+ * Most AT clients should use the #AccessibleAction interface when
+ * tempted to generate mouse events, rather than this method.
* Not Yet Implemented.
*
**/