static void *doAtSpiScreenOpen(void *arg) { AccessibleEventListener *evListener; sem_t *SPI_init_sem = (sem_t *)arg; int res; static const char *events[] = { "object:text-changed", "object:text-caret-moved", "object:state-changed:focused", "focus:", }; const char **event; if ((res=SPI_init())) { logMessage(LOG_ERR,"SPI_init returned %d",res); return 0; } if (!(evListener = SPI_createAccessibleEventListener(evListenerCB,NULL))) logMessage(LOG_ERR,"SPI_createAccessibleEventListener failed"); else for (event=events; event<&events[sizeof(events)/sizeof(*events)]; event++) if (!(SPI_registerGlobalEventListener(evListener,*event))) logMessage(LOG_ERR,"SPI_registerGlobalEventListener(%s) failed",*event); sem_post(SPI_init_sem); SPI_event_main(); if (!(SPI_deregisterGlobalEventListenerAll(evListener))) logMessage(LOG_ERR,"SPI_deregisterGlobalEventListenerAll failed"); AccessibleEventListener_unref(evListener); if (curFocus) finiTerm(); if ((res=SPI_exit())) logMessage(LOG_ERR,"SPI_exit returned %d",res); return NULL; }
int main (int argc, char **argv) { AccessibleKeySet switch_set; if ((argc > 1) && (!strncmp (argv[1], "-h", 2))) { printf ("Usage: keysynth-demo\n"); exit (1); } gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */ SPI_init (); key_listener = SPI_createAccessibleKeystrokeListener (is_command_key, NULL); /* will listen only to Alt-key combinations */ SPI_registerAccessibleKeystrokeListener (key_listener, (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL, (unsigned long) ( KeyPress | KeyRelease), SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS); create_vkbd (); /* * Register a listener on an 'unused' key, to serve as a 'single switch'. * On most Intel boxes there is at least one 'special' system key that does not * have a non-zero keycode assigned in the Xserver, so we will intercept any keycode * that is 'zero'. Often these the are the "windows" or the "menu" keys. */ switch_set.keysyms = g_new0 (unsigned long, 1); switch_set.keycodes = g_new0 (unsigned short, 1); switch_set.keystrings = g_new0 (char *, 1); switch_set.len = 1; switch_set.keysyms[0] = (unsigned long) 0; switch_set.keycodes[0] = (unsigned short) 0; switch_set.keystrings[0] = ""; 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_NOSYNC); SPI_event_main (); return SPI_exit (); }
int Server::run(int argc, char* argv[]) { int ret; if ((ret = SPI_init())) return ret; shutdownOnInterrupt(); Ice::ObjectAdapterPtr adapter = communicator()-> createObjectAdapterWithEndpoints("Guitar", "default -p 10000"); guitarlib::ApplicationI *app = new guitarlib::ApplicationI(adapter); adapter->add(app, communicator()->stringToIdentity("Application")); adapter->activate(); communicator()->waitForShutdown(); ret = SPI_exit(); return ret; }
int main (int argc, char **argv) { int leaked, i; TestWindow *win; const char *modules; AccessibleEventListener *global_listener; modules = g_getenv ("GTK_MODULES"); if (!modules || modules [0] == '\0') putenv ("GTK_MODULES=gail:atk-bridge"); modules = NULL; for (i = 1; i < argc; i++) { if (!g_strcasecmp (argv [i], "--poke")) do_poke = TRUE; } gtk_init (&argc, &argv); g_assert (!SPI_init ()); g_assert (SPI_init ()); g_assert (SPI_getDesktopCount () == 1); test_roles (); test_misc (); test_desktop (); test_keylisteners (); win = create_test_window (); global_listener = SPI_createAccessibleEventListener (global_listener_cb, win); g_assert (SPI_registerGlobalEventListener (global_listener, "focus:")); fprintf (stderr, "Waiting for focus event ...\n"); gtk_main (); g_assert (SPI_deregisterGlobalEventListenerAll (global_listener)); AccessibleEventListener_unref (global_listener); test_window_destroy (win); /* Wait for any pending events from the registry */ g_usleep (500*1000); for (i = 0; i < 100; i++) dbus_connection_read_write_dispatch (SPI_bus(), 5); if ((leaked = SPI_exit ())) g_error ("Leaked %d SPI handles", leaked); g_assert (!SPI_exit ()); fprintf (stderr, "All tests passed\n"); if (g_getenv ("_MEMPROF_SOCKET")) { fprintf (stderr, "Waiting for memprof\n"); gtk_main (); } putenv ("AT_BRIDGE_SHUTDOWN=1"); return 0; }
void windows_deinit_subsystem () { SPI_exit(); }
int main (int argc, char **argv) { const char *tab_strings[1] = {"Tab"}; short keycodes[] = {65, 64, 23}; SPIBoolean retval = FALSE; SPI_init (); /* prepare the keyboard snoopers */ command_key_listener = SPI_createAccessibleKeystrokeListener (report_command_key_event, NULL); ordinary_key_listener = SPI_createAccessibleKeystrokeListener (report_ordinary_key_event, NULL); synchronous_key_listener = SPI_createAccessibleKeystrokeListener (report_synchronous_key_event, NULL); tab_key_listener = SPI_createAccessibleKeystrokeListener (report_tab_key_event, NULL); all_key_listener = SPI_createAccessibleKeystrokeListener (report_all_key_event, NULL); 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_keyset = SPI_createAccessibleKeySet (1, NULL, NULL, tab_strings); retval = SPI_registerAccessibleKeystrokeListener(command_key_listener, command_keyset, SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL, (unsigned long) ( SPI_KEY_PRESSED ), SPI_KEYLISTENER_ALL_WINDOWS); fprintf (stderr, "Command key registry: result %s\n", retval ? "succeeded" : "failed"); retval = SPI_registerAccessibleKeystrokeListener(ordinary_key_listener, async_keyset, SPI_KEYMASK_UNMODIFIED, (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), SPI_KEYLISTENER_NOSYNC); retval = SPI_registerAccessibleKeystrokeListener(synchronous_key_listener, sync_keyset, SPI_KEYMASK_UNMODIFIED, (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), SPI_KEYLISTENER_CANCONSUME); retval = SPI_registerAccessibleKeystrokeListener(tab_key_listener, tab_keyset, SPI_KEYMASK_ALT, (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), SPI_KEYLISTENER_ALL_WINDOWS); fprintf (stderr, "tab listener registry: %s\n", retval ? "succeeded" : "failed"); retval = SPI_registerAccessibleKeystrokeListener(all_key_listener, SPI_KEYSET_ALL_KEYS, SPI_KEYMASK_CONTROL | SPI_KEYMASK_SHIFT, (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ), SPI_KEYLISTENER_ALL_WINDOWS); fprintf (stderr, "all key registry: %s\n", retval ? "succeeded" : "failed" ); SPI_registerAccessibleKeystrokeListener(all_key_listener, SPI_KEYSET_ALL_KEYS, SPI_KEYMASK_SHIFT, (unsigned long) ( SPI_KEY_PRESSED ), SPI_KEYLISTENER_NOSYNC | SPI_KEYLISTENER_CANCONSUME); SPI_event_main (); putenv ("AT_BRIDGE_SHUTDOWN=1"); return SPI_exit (); }
int main (int argc, char **argv) { pid_t pid; gboolean delay_click = FALSE; gboolean dwell_click = FALSE; gdouble delay_time = -1.; gdouble dwell_time = -1.; gboolean shutdown = FALSE; gboolean ctw = FALSE; gboolean animate = FALSE; gchar *mode = NULL; gint pos_x = -1; gint pos_y = -1; gint threshold = -1; GOptionContext *context; GOptionEntry entries[] = { {"enable-dwell", 0, 0, G_OPTION_ARG_NONE, &dwell_click, N_("Enable dwell click"), 0}, {"enable-secondary", 0, 0, G_OPTION_ARG_NONE, &delay_click, N_("Enable simulated secondary click"), 0}, {"dwell-time", 0, 0, G_OPTION_ARG_DOUBLE, &dwell_time, N_("Time to wait before a dwell click"), "[0.2-3.0]"}, {"secondary-time", 0, 0, G_OPTION_ARG_DOUBLE, &delay_time, N_("Time to wait before a simulated secondary click"), "[0.5-3.0]"}, {"dwell-mode", 'm', 0, G_OPTION_ARG_STRING, &mode, N_("Dwell mode to use"), "[window|gesture]"}, {"show-ctw", 'c', 0, G_OPTION_ARG_NONE, &ctw, N_("Show click type window"), 0}, {"ctw-x", 'x', 0, G_OPTION_ARG_INT, &pos_x, N_("Window x position"), 0}, {"ctw-y", 'y', 0, G_OPTION_ARG_INT, &pos_y, N_("Window y position"), 0}, {"threshold", 't', 0, G_OPTION_ARG_INT, &threshold, N_("Ignore small pointer movements"), "[0-30]"}, {"animate-cursor", 'a', 0, G_OPTION_ARG_NONE, &animate, N_("Show elapsed time as cursor overlay"), 0}, {"shutdown", 's', 0, G_OPTION_ARG_NONE, &shutdown, N_("Shut down mousetweaks"), 0}, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); context = g_option_context_new (_("- GNOME mousetweaks daemon")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); if (shutdown) { int ret; if ((ret = mt_pidfile_kill_wait (SIGINT, 5)) < 0) g_print ("Shutdown failed or nothing to shut down.\n"); else g_print ("Shutdown successful.\n"); return ret < 0 ? 1 : 0; } if ((pid = mt_pidfile_is_running ()) >= 0) { g_print ("Daemon is already running. (PID %u)\n", pid); return 1; } g_print ("Starting daemon.\n"); if ((pid = fork ()) < 0) { g_error ("fork() failed."); return 1; } else if (pid) { /* Parent return */ return 0; } else { /* Child process */ MTClosure *mt; MtCursorManager *manager; MtListener *listener; gint spi_status; gint spi_leaks = 0; if (mt_pidfile_create () < 0) return 1; signal (SIGINT, signal_handler); signal (SIGTERM, signal_handler); signal (SIGQUIT, signal_handler); signal (SIGHUP, signal_handler); gtk_init (&argc, &argv); g_set_application_name ("Mousetweaks"); mt = mt_closure_init (); if (!mt) goto FINISH; spi_status = SPI_init (); if (!accessibility_enabled (mt, spi_status)) { mt_closure_free (mt); goto FINISH; } /* command-line options */ if (dwell_click) gconf_client_set_bool (mt->client, OPT_DWELL, TRUE, NULL); if (delay_click) gconf_client_set_bool (mt->client, OPT_DELAY, TRUE, NULL); if (delay_time >= .5 && delay_time <= 3.) gconf_client_set_float (mt->client, OPT_DELAY_T, delay_time, NULL); if (dwell_time >= .2 && dwell_time <= 3.) gconf_client_set_float (mt->client, OPT_DWELL_T, dwell_time, NULL); if (threshold >= 0 && threshold <= 30) gconf_client_set_int (mt->client, OPT_THRESHOLD, threshold, NULL); if (ctw) gconf_client_set_bool (mt->client, OPT_CTW, TRUE, NULL); if (animate) gconf_client_set_bool (mt->client, OPT_ANIMATE, TRUE, NULL); if (mode) { if (g_str_equal (mode, "gesture")) gconf_client_set_int (mt->client, OPT_MODE, DWELL_MODE_GESTURE, NULL); else if (g_str_equal (mode, "window")) gconf_client_set_int (mt->client, OPT_MODE, DWELL_MODE_CTW, NULL); g_free (mode); } get_gconf_options (mt); if (!mt_ctw_init (mt, pos_x, pos_y)) goto CLEANUP; /* init cursor animation */ manager = mt_cursor_manager_get_default (); g_signal_connect (manager, "cursor_changed", G_CALLBACK (cursor_changed), mt); g_signal_connect (manager, "cache_cleared", G_CALLBACK (cursor_cache_cleared), mt); mt->cursor = mt_cursor_manager_current_cursor (manager); /* init at-spi signals */ listener = mt_listener_get_default (); g_signal_connect (listener, "motion_event", G_CALLBACK (global_motion_event), mt); g_signal_connect (listener, "button_event", G_CALLBACK (global_button_event), mt); g_signal_connect (listener, "focus_changed", G_CALLBACK (global_focus_event), mt); gtk_main (); mt_cursor_manager_restore_all (manager); g_object_unref (manager); g_object_unref (listener); CLEANUP: spi_leaks = SPI_exit (); mt_closure_free (mt); FINISH: mt_pidfile_remove (); if (spi_leaks) g_warning ("AT-SPI reported %i leak%s.", spi_leaks, spi_leaks != 1 ? "s" : ""); } return 0; }
static void closedown( Driver* dp ) { Accessible_unref( dp->frame ); int leaks = SPI_exit(); report_if_error( "There were %d SPI memory leaks.", leaks ); }
int main(int argc, char** argv) { SPI_init(); SPI_exit(); return 0; }