Added support for key event strings, and renamespaced some of the at-bridge.
[platform/core/uifw/at-spi2-atk.git] / test / simple-at.c
index 1901e68..35ffec3 100644 (file)
@@ -50,6 +50,7 @@ static AccessibleEventListener *generic_listener;
 static AccessibleEventListener *button_listener;
 static AccessibleKeystrokeListener *command_key_listener;
 static AccessibleKeystrokeListener *ordinary_key_listener;
+static AccessibleKeySet *spacebar_key_set;
 
 int
 main (int argc, char **argv)
@@ -119,22 +120,32 @@ main (int argc, char **argv)
   SPI_registerAccessibleKeystrokeListener(command_key_listener,
                                          (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
                                          SPI_KEYMASK_ALT,
-                                         (unsigned long) ( KeyPress ),
+                                         (unsigned long) ( SPI_KEY_PRESSED ),
                                          SPI_KEYLISTENER_ALL_WINDOWS);
   
   /* will listen only to unshifted key events, both press and release */
   SPI_registerAccessibleKeystrokeListener(ordinary_key_listener,
                                          (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
                                          SPI_KEYMASK_UNMODIFIED,
-                                         (unsigned long) ( KeyPress | KeyRelease),
+                                         (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
                                          SPI_KEYLISTENER_NOSYNC);
                                      
   /* will listen only to shifted key events, both press and release */
   SPI_registerAccessibleKeystrokeListener(ordinary_key_listener,
                                          (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
                                          SPI_KEYMASK_SHIFT,
-                                         (unsigned long) ( KeyPress | KeyRelease),
+                                         (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
                                          SPI_KEYLISTENER_NOSYNC);
+
+  spacebar_key_set = SPI_createAccessibleKeySet (1, " ", NULL, NULL);
+  
+  /* will listen only to shift-spacebar events, on release, globally */
+  SPI_registerAccessibleKeystrokeListener(command_key_listener,
+                                         spacebar_key_set,
+                                         SPI_KEYMASK_SHIFT,
+                                         (unsigned long) ( SPI_KEY_RELEASED ),
+                                         SPI_KEYLISTENER_ALL_WINDOWS);
+
   
   get_environment_vars ();
 
@@ -324,6 +335,8 @@ simple_at_exit ()
   SPI_deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_UNMODIFIED);
   SPI_deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_SHIFT);
   AccessibleKeystrokeListener_unref         (ordinary_key_listener);
+
+  SPI_freeAccessibleKeySet (spacebar_key_set);
   
   SPI_event_quit ();
 }
@@ -353,11 +366,13 @@ is_command_key (AccessibleKeystroke *key)
 static SPIBoolean
 report_command_key_event (AccessibleKeystroke *key, void *user_data)
 {
-  fprintf (stderr, "Command KeyEvent %s%c (keycode %d)\n",
+  fprintf (stderr, "Command KeyEvent %s%c (keycode %d); string=%s; time=%lx\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);
+         (int) key->keycode,
+         key->keystring,
+         (long int) key->timestamp);
   return is_command_key (key);
 }
 
@@ -365,10 +380,11 @@ report_command_key_event (AccessibleKeystroke *key, void *user_data)
 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",
+  fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\tstring=\'%s\'\n\ttime %lx\n",
           (long) key->keyID,
           (unsigned int) key->modifiers,
           (int) key->keycode,
+          key->keystring,
           (long int) key->timestamp);
   return FALSE;
 }