static boolean use_festival = FALSE;
static boolean festival_chatty = FALSE;
+static AccessibleEventListener *focus_listener;
+static AccessibleEventListener *property_listener;
+static AccessibleEventListener *button_listener;
+static AccessibleKeystrokeListener *key_listener;
+
int
main(int argc, char **argv)
{
int n_apps;
Accessible *desktop;
Accessible *application;
- AccessibleEventListener *focus_listener;
- AccessibleEventListener *property_listener;
- AccessibleEventListener *button_listener;
- KeystrokeListener *key_listener;
if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
{
SPI_init();
- focus_listener = createEventListener (report_focus_event);
- property_listener = createEventListener (check_property_change);
- button_listener = createEventListener (report_button_press);
+ focus_listener = createAccessibleEventListener (report_focus_event);
+ property_listener = createAccessibleEventListener (check_property_change);
+ button_listener = createAccessibleEventListener (report_button_press);
registerGlobalEventListener (focus_listener, "focus:");
registerGlobalEventListener (property_listener, "object:property-change:accessible-selection");
registerGlobalEventListener (button_listener, "Gtk:GtkWidget:button-press-event");
}
/* prepare the keyboard snoopers */
- /* key_listener = createKeystrokeListener(report_key_event);
- registerKeystrokeListener(key_listener, KEYMASK_SHIFT); */
+ key_listener = createAccessibleKeystrokeListener(report_key_event);
+ /* will listen only to Alt-key combinations */
+ registerAccessibleKeystrokeListener(key_listener,
+ (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
+ SPI_KEYMASK_ALT,
+ (unsigned long) ( KeyPress | KeyRelease),
+ SPI_KEYLISTENER_ALL_WINDOWS);
get_environment_vars();
- SPI_event_main(FALSE);
+ SPI_event_main(TRUE);
}
static void
long x, y, width, height;
AccessibleComponent *component = Accessible_getComponent (obj);
AccessibleComponent_getExtents (component, &x, &y, &width, &height,
- COORD_TYPE_SCREEN);
+ SPI_COORD_TYPE_SCREEN);
fprintf (stderr, "Bounding box: (%ld, %ld) ; (%ld, %ld)\n",
x, y, x+width, y+height);
if (use_magnifier) {
- magnifier_set_roi (x, y, width, height);
+ magnifier_set_roi ((short) 0, x, y, width, height);
}
}
/* if this is a text object, speak the first sentence. */
+
if (Accessible_isText(obj))
+
{
AccessibleText *text_interface;
long start_offset, end_offset;
text_interface = Accessible_getText (obj);
fprintf (stderr, "isText...%p %p\n", text_interface, (void *)*text_interface);
first_sentence = AccessibleText_getTextAtOffset (
- text_interface, (long) 0, TEXT_BOUNDARY_SENTENCE_START, &start_offset, &end_offset);
+ text_interface, (long) 0, SPI_TEXT_BOUNDARY_SENTENCE_START, &start_offset, &end_offset);
if (first_sentence) _festival_say(first_sentence, "voice_don_diphone", FALSE);
fprintf (stderr, "done reporting on focussed object\n");
}
AccessibleEvent *ev = (AccessibleEvent *) p;
fprintf (stderr, "%s event from %s\n", ev->type,
Accessible_getName (&ev->source));
+ fprintf (stderr, "Object description %s\n",
+ Accessible_getDescription (&ev->source));
}
}
}
+static void
+simple_at_exit()
+{
+ deregisterGlobalEventListenerAll (focus_listener);
+ deregisterGlobalEventListenerAll (property_listener);
+ deregisterGlobalEventListenerAll (button_listener);
+ deregisterAccessibleKeystrokeListener (key_listener, SPI_KEYMASK_ALT );
+
+ SPI_exit ();
+}
+
+static boolean
+is_command_key (AccessibleKeyStroke *key)
+{
+ switch (key->keyID)
+ {
+ case 'Q':
+ case 'q':
+ simple_at_exit();
+ return TRUE; /* not reached */
+ case 'M':
+ case 'm':
+ use_magnifier = ! use_magnifier;
+ return TRUE;
+ case 'F':
+ case 'f':
+ use_festival = ! use_festival;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
static boolean
report_key_event (void *p)
{
- KeyStroke *key = (KeyStroke *) p;
- fprintf (stderr, ".");
- return FALSE;
+ AccessibleKeyStroke *key = (AccessibleKeyStroke *) p;
+ fprintf (stderr, "KeyEvent %s%c (keycode %d)\n",
+ (key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"",
+ ((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))?
+ (char) toupper((int) key->keyID) : (char) tolower((int) key->keyID),
+ (int) key->keycode);
+ fprintf (stderr, "Key:\tsym %ld\n\tmods %x\n\tcode %d\n\ttime %ld\n",
+ (long) key->keyID,
+ (unsigned int) key->modifiers,
+ (int) key->keycode,
+ (long int) key->timestamp);
+ return is_command_key (key);
}
static int _festival_init ()