Added support for key event strings, and renamespaced some of the at-bridge.
[platform/core/uifw/at-spi2-atk.git] / test / keysynth-demo.c
index 79b6f41..ebf00c1 100644 (file)
@@ -278,11 +278,15 @@ toggle_shift_latch (GtkButton *button)
 }
 
 static void
-keysynth_exit()
+keysynth_exit (void)
 {
-  deregisterAccessibleKeystrokeListener (key_listener, SPI_KEYMASK_ALT );
-  deregisterAccessibleKeystrokeListener (switch_listener, SPI_KEYMASK_UNMODIFIED );
-  SPI_exit ();
+  SPI_deregisterAccessibleKeystrokeListener (key_listener, SPI_KEYMASK_ALT);
+  AccessibleKeystrokeListener_unref         (key_listener);
+
+  SPI_deregisterAccessibleKeystrokeListener (switch_listener, SPI_KEYMASK_UNMODIFIED);
+  AccessibleKeystrokeListener_unref         (switch_listener);
+
+  SPI_event_quit ();
 }
 
 static void
@@ -309,9 +313,9 @@ keysynth_realize (GtkWidget *widget)
 }
 
 static void
-button_exit(GtkButton *notused, void *alsonotused)
+button_exit (GtkButton *notused, void *alsonotused)
 {
-  keysynth_exit();
+  keysynth_exit ();
 }
 
 static SPIBoolean
@@ -321,7 +325,7 @@ is_command_key (AccessibleKeystroke *key, void *user_data)
     {
     case 'Q':
     case 'q':
-           keysynth_exit(); 
+           keysynth_exit (); 
            return TRUE; /* not reached */
     }
   return FALSE;
@@ -363,13 +367,13 @@ synth_keycode (GtkButton *button, KeyCode *keycode)
           label_buttons (caps_lock || shift_latched);
         }
       if (shift_latched)
-             generateKeyEvent (shift_keycode, SPI_KEY_PRESS);
+             SPI_generateKeyEvent (shift_keycode, SPI_KEY_PRESS);
       
-      generateKeyEvent ((long) *keycode, SPI_KEY_PRESSRELEASE);
+      SPI_generateKeyEvent ((long) *keycode, SPI_KEY_PRESSRELEASE);
 
       if (shift_latched)
         {
-         generateKeyEvent (shift_keycode, SPI_KEY_RELEASE);
+         SPI_generateKeyEvent (shift_keycode, SPI_KEY_RELEASE);
          toggle_shift_latch (button);
        }
     }
@@ -456,11 +460,11 @@ create_vkbd()
 }
 
 int
-main(int argc, char **argv)
+main (int argc, char **argv)
 {
   AccessibleKeySet switch_set;
   
-  if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
+  if ((argc > 1) && (!strncmp (argv[1], "-h", 2)))
     {
       printf ("Usage: keysynth-demo\n");
       exit (1);
@@ -468,15 +472,15 @@ main(int argc, char **argv)
 
   gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */
 
-  SPI_init (TRUE);
+  SPI_init ();
 
-  key_listener = createAccessibleKeystrokeListener (is_command_key, NULL);
+  key_listener = SPI_createAccessibleKeystrokeListener (is_command_key, NULL);
   /* will listen only to Alt-key combinations */
-  registerAccessibleKeystrokeListener (key_listener,
-                                      (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
-                                      SPI_KEYMASK_ALT,
-                                      (unsigned long) ( KeyPress | KeyRelease),
-                                      SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
+  SPI_registerAccessibleKeystrokeListener (key_listener,
+                                          (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS,
+                                          SPI_KEYMASK_ALT,
+                                          (unsigned long) ( KeyPress | KeyRelease),
+                                          SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS);
   create_vkbd ();  
 
   /*
@@ -490,14 +494,14 @@ main(int argc, char **argv)
   switch_set.len = 1;
   switch_set.keysyms[0] = (unsigned long) 0;
   switch_set.keycodes[0] = (unsigned short) 0;
-  switch_listener = createAccessibleKeystrokeListener (switch_callback, NULL);
-  registerAccessibleKeystrokeListener (switch_listener,
-                                      &switch_set,
-                                      SPI_KEYMASK_UNMODIFIED,
-                                      (unsigned long) ( KeyPress | KeyRelease),
-                                      SPI_KEYLISTENER_CANCONSUME);
+  switch_listener = SPI_createAccessibleKeystrokeListener (switch_callback, NULL);
+  SPI_registerAccessibleKeystrokeListener (switch_listener,
+                                          &switch_set,
+                                          SPI_KEYMASK_UNMODIFIED,
+                                          (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
+                                          SPI_KEYLISTENER_CANCONSUME);
   
   SPI_event_main ();
 
-  return 0;
+  return SPI_exit ();
 }