Exemple #1
0
static void
simple_at_exit (void)
{
  SPI_deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL);
  AccessibleKeystrokeListener_unref         (command_key_listener);
  SPI_freeAccessibleKeySet                  (command_keyset);
  
/*
  SPI_deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); */
  AccessibleKeystrokeListener_unref         (ordinary_key_listener);
  SPI_freeAccessibleKeySet                  (async_keyset);
  
/*  SPI_deregisterAccessibleKeystrokeListener (synchronous_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL); */
  AccessibleKeystrokeListener_unref         (synchronous_key_listener);
  SPI_freeAccessibleKeySet                  (sync_keyset);

  SPI_deregisterAccessibleKeystrokeListener (tab_key_listener, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL);
  AccessibleKeystrokeListener_unref         (tab_key_listener);
  SPI_freeAccessibleKeySet                  (tab_keyset);

  SPI_event_quit ();
}
static void
test_keylisteners (void)
{
	int i;
	AccessibleKeystroke stroke;
	AccessibleKeystrokeListener *key_listener;
	AccessibleKeySet *test_keyset;

	fprintf (stderr, "Testing keyboard listeners ...\n");

	key_listener = SPI_createAccessibleKeystrokeListener (
		key_listener_cb, &stroke);

	test_keyset = SPI_createAccessibleKeySet (1, "=", NULL, NULL);

	g_assert (SPI_registerAccessibleKeystrokeListener (
		key_listener,
		test_keyset,
		0,
		SPI_KEY_PRESSED | SPI_KEY_RELEASED,
		SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS));

	for (i = 0; i < 3; i++) {
		memset (&stroke, 0, sizeof (AccessibleKeystroke));
		g_assert (SPI_generateKeyboardEvent ('=', NULL, SPI_KEY_SYM));
		while (!(key_press_received))
			g_main_context_iteration (NULL, TRUE);
		fprintf (stderr, "p [%s]", stroke.keystring);
	        g_assert (!strcmp (stroke.keystring, "="));
		while (!(key_release_received))
			g_main_context_iteration (NULL, TRUE);
		fprintf (stderr, "r [%s]", stroke.keystring);
		key_press_received = FALSE;
		key_release_received = FALSE;
	}
	g_assert (SPI_deregisterAccessibleKeystrokeListener (key_listener, 0));
	SPI_freeAccessibleKeySet (test_keyset);

	fprintf (stderr, "\n");

	AccessibleKeystrokeListener_unref (key_listener);

	g_assert (SPI_generateMouseEvent (100, 100, "rel"));
        g_assert (SPI_generateMouseEvent (-50, -50, "rel"));		  
        g_assert (SPI_generateMouseEvent (-50, -50, "rel"));		  
        g_assert (SPI_generateMouseEvent (-1, -1, "b1c")); 
}