Add a check for lack of memory
[platform/core/uifw/at-spi2-atk.git] / test / key-listener-test.c
index 2a2d78d..5c7d43d 100644 (file)
@@ -2,7 +2,8 @@
  * AT-SPI - Assistive Technology Service Provider Interface
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,7 +28,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
-#include <spi.h>
+#include <cspi/spi.h>
 
 static SPIBoolean report_command_key_event  (const AccessibleKeystroke *stroke, void *user_data);
 static SPIBoolean report_ordinary_key_event (const AccessibleKeystroke *stroke, void *user_data);
@@ -48,7 +49,7 @@ static AccessibleKeySet            *tab_keyset;
 int
 main (int argc, char **argv)
 {
-  char *tab_strings[1];
+  const char *tab_strings[1] = {"Tab"};
   short keycodes[] = {65, 64, 23};
   SPIBoolean retval = FALSE;
        
@@ -64,7 +65,6 @@ main (int argc, char **argv)
   command_keyset = SPI_createAccessibleKeySet (1, "q", NULL, NULL);
   async_keyset = SPI_createAccessibleKeySet (3, NULL, keycodes, NULL);
   sync_keyset = SPI_createAccessibleKeySet (3, "def", NULL, NULL);
-  tab_strings[0] = "Tab";
   tab_keyset = SPI_createAccessibleKeySet (1,  NULL, NULL, tab_strings);
   retval = SPI_registerAccessibleKeystrokeListener(command_key_listener,
                                          command_keyset,
@@ -94,7 +94,7 @@ main (int argc, char **argv)
 
   retval = SPI_registerAccessibleKeystrokeListener(all_key_listener,
                                          SPI_KEYSET_ALL_KEYS,
-                                         SPI_KEYMASK_CONTROL,
+                                         SPI_KEYMASK_CONTROL | SPI_KEYMASK_SHIFT,
                                          (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
                                          SPI_KEYLISTENER_ALL_WINDOWS);
        
@@ -102,9 +102,9 @@ main (int argc, char **argv)
 
   SPI_registerAccessibleKeystrokeListener(all_key_listener,
                                         SPI_KEYSET_ALL_KEYS,
-                                        SPI_KEYMASK_UNMODIFIED,
-                                        (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
-                                        SPI_KEYLISTENER_NOSYNC);
+                                        SPI_KEYMASK_SHIFT,
+                                        (unsigned long) ( SPI_KEY_PRESSED ),
+                                        SPI_KEYLISTENER_NOSYNC | SPI_KEYLISTENER_CANCONSUME);
 
   SPI_event_main ();
 
@@ -114,7 +114,7 @@ main (int argc, char **argv)
 }
 
 static void
-simple_at_exit ()
+simple_at_exit (void)
 {
   SPI_deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL);
   AccessibleKeystrokeListener_unref         (command_key_listener);
@@ -195,7 +195,7 @@ report_tab_key_event (const AccessibleKeystroke *key, void *user_data)
 static SPIBoolean
 report_all_key_event (const AccessibleKeystroke *key, void *user_data)
 {
-  g_print("(%d)", key->keyID);
+  fprintf(stderr, "(%ld)", key->keyID);
   return FALSE;
 }