X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Fsimple-at.c;h=1e66ef1669b8535ebfa52b5ea14dec75f5fbafad;hb=8d44f439f509885221b67efc841a1b429cdd8236;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..1e66ef1 100644 --- a/test/simple-at.c +++ b/test/simple-at.c @@ -21,49 +21,57 @@ */ #include +#include +#include #include #include -#include "spi.h" - -static void report_focus_event (void *fp); -static void report_button_press (void *fp); -static boolean report_key_event (void *fp); -static void check_property_change (void *fp); +#include +#include "../util/mag_client.h" +#include "../cspi/spi-private.h" /* A hack for now */ + +static void report_focus_event (AccessibleEvent *event, void *user_data); +static void report_button_press (AccessibleEvent *event, void *user_data); +static void check_property_change (AccessibleEvent *event, void *user_data); +static SPIBoolean report_command_key_event (AccessibleKeystroke *stroke, void *user_data); +static SPIBoolean report_ordinary_key_event (AccessibleKeystroke *stroke, void *user_data); static void get_environment_vars (void); static int _festival_init (); -static void _festival_say (const char *text, const char *voice, boolean shutup); +static void _festival_say (const char *text, const char *voice, SPIBoolean shutup); static void _festival_write (const char *buff, int fd); -static boolean use_magnifier = FALSE; -static boolean use_festival = FALSE; -static boolean festival_chatty = FALSE; +static SPIBoolean use_magnifier = FALSE; +static SPIBoolean use_festival = FALSE; +static SPIBoolean festival_chatty = FALSE; + +static AccessibleEventListener *focus_listener; +static AccessibleEventListener *property_listener; +static AccessibleEventListener *button_listener; +static AccessibleKeystrokeListener *command_key_listener; +static AccessibleKeystrokeListener *ordinary_key_listener; int -main(int argc, char **argv) +main (int argc, char **argv) { int i, j; int n_desktops; int n_apps; Accessible *desktop; Accessible *application; - AccessibleEventListener *focus_listener; - AccessibleEventListener *property_listener; - AccessibleEventListener *button_listener; - KeystrokeListener *key_listener; + char *s; - if ((argc > 1) && (!strncmp(argv[1],"-h",2))) + if ((argc > 1) && (!strncmp (argv[1], "-h", 2))) { printf ("Usage: simple-at\n"); printf ("\tEnvironment variables used:\n\t\tFESTIVAL\n\t\tMAGNIFIER\n\t\tFESTIVAL_CHATTY\n"); - exit(0); + exit (0); } - SPI_init(); + 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, NULL); + property_listener = createAccessibleEventListener (check_property_change, NULL); + button_listener = createAccessibleEventListener (report_button_press, NULL); registerGlobalEventListener (focus_listener, "focus:"); registerGlobalEventListener (property_listener, "object:property-change:accessible-selection"); registerGlobalEventListener (button_listener, "Gtk:GtkWidget:button-press-event"); @@ -72,45 +80,82 @@ main(int argc, char **argv) for (i=0; itype, - Accessible_getName (&ev->source)); - report_focussed_accessible (&ev->source, TRUE); + char *s; + + g_warning ("report focus event"); + + g_return_if_fail (event->source != NULL); + + s = Accessible_getName (event->source); + if (cspi_warn_ev (cspi_ev (), "Foobar")) + { + fprintf (stderr, "%s event from %s\n", event->type, s); + SPI_freeString (s); + report_focussed_accessible (event->source, TRUE); + } + Accessible_getParent (event->source); } void -report_button_press (void *p) +report_button_press (AccessibleEvent *event, void *user_data) { - AccessibleEvent *ev = (AccessibleEvent *) p; - fprintf (stderr, "%s event from %s\n", ev->type, - Accessible_getName (&ev->source)); -} + char *s; + + g_return_if_fail (event->source != NULL); + s = Accessible_getName (event->source); + + fprintf (stderr, "%s event from %s\n", event->type, s); + SPI_freeString (s); + s = Accessible_getDescription (event->source); + fprintf (stderr, "Object description %s\n", s); + SPI_freeString (s); +} void -check_property_change (void *p) +check_property_change (AccessibleEvent *event, void *user_data) { - AccessibleEvent *ev = (AccessibleEvent *) p; - AccessibleSelection *selection = Accessible_getSelection (&ev->source); + AccessibleSelection *selection = Accessible_getSelection (event->source); int n_selections; int i; + char *s; if (selection) { n_selections = (int) AccessibleSelection_getNSelectedChildren (selection); - fprintf (stderr, "(Property) %s event from %s, %d selected children\n", ev->type, - Accessible_getName (&ev->source), n_selections); + s = Accessible_getName (event->source); + fprintf (stderr, "(Property) %s event from %s, %d selected children\n", + event->type, s, n_selections); + SPI_freeString (s); /* for now, speak entire selection set */ for (i=0; ikeyID) + { + 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 SPIBoolean +report_command_key_event (AccessibleKeystroke *key, void *user_data) { - KeyStroke *key = (KeyStroke *) p; - fprintf (stderr, "."); + fprintf (stderr, "Command 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); + return is_command_key (key); +} + + +static SPIBoolean +report_ordinary_key_event (AccessibleKeystroke *key, void *user_data) +{ + fprintf (stderr, "Received key event:\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 FALSE; } -static int _festival_init () +static int +_festival_init () { int fd; struct sockaddr_in name; @@ -222,7 +356,8 @@ static int _festival_init () return fd; } -static void _festival_say (const char *text, const char *voice, boolean shutup) +static void +_festival_say (const char *text, const char *voice, SPIBoolean shutup) { static int fd = 0; gchar *quoted; @@ -267,7 +402,8 @@ static void _festival_say (const char *text, const char *voice, boolean shutup) g_free(quoted); } -static void _festival_write (const gchar *command_string, int fd) +static void +_festival_write (const gchar *command_string, int fd) { fprintf(stderr, command_string); if (fd < 0) {