X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Fsimple-at.c;h=1a532a48f0585abd3def212868583bd6a950592d;hb=4328426aeae1eeed7c2e696536351b224eeddbce;hp=749bcf1b795a734a3a7736040d342ef928d8100e;hpb=7ff7c0d0b863f7346f21e03b6d170e8c7c6f9878;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/test/simple-at.c b/test/simple-at.c index 749bcf1..1a532a4 100644 --- a/test/simple-at.c +++ b/test/simple-at.c @@ -39,6 +39,11 @@ static boolean use_magnifier = FALSE; 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) { @@ -47,10 +52,6 @@ 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))) { @@ -61,9 +62,9 @@ main(int argc, char **argv) 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"); @@ -83,12 +84,17 @@ main(int argc, char **argv) } /* 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 @@ -127,15 +133,17 @@ report_focussed_accessible (Accessible *obj, boolean shutup_previous_speech) 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; @@ -143,7 +151,7 @@ report_focussed_accessible (Accessible *obj, boolean shutup_previous_speech) 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"); } @@ -164,6 +172,8 @@ report_button_press (void *p) 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)); } @@ -190,12 +200,54 @@ check_property_change (void *p) } } +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 ()