? gok/GNOME_Gok.server
? gok/GNOME_Gok.server.in
? gok/create-branching-keyboard
? gok/keyboard-geometry
? gok/test-gok-wordcomplete
Index: gok/main.c
===================================================================
RCS file: /cvs/gnome/gok/gok/main.c,v
retrieving revision 1.183
diff -u -r1.183 main.c
--- gok/main.c	19 May 2005 14:06:13 -0000	1.183
+++ gok/main.c	15 Sep 2005 13:56:15 -0000
@@ -88,6 +88,10 @@
 
 static gboolean respawn_on_segv = TRUE;
 
+static gboolean queue_input_events = TRUE;
+
+static guint input_idle_handler = 0;
+
 static GokApplication *_gok_app = NULL;
 
 /* pointer to the first keyboard in the list of keyboards */
@@ -141,6 +145,11 @@
 
 static GokArgs gok_args;
 
+static struct {
+    gint n_axes;
+    int *axes;
+} gok_motion_event = {0, 0x0000};
+
 /* Private functions */
 static void gok_main_read_rc (void);
 static void gok_main_initialize_access_methods (GokArgs *args);
@@ -1096,6 +1105,36 @@
 	}
 }	
 
+/** 
+ * gok_main_check_input_queue (gpointer data):
+ *
+ * Check the extended input event queue and act on the most recent motion event,
+ * and discard other motion events.
+ * 
+ * returns: FALSE as specified in g_idle_add ().
+ **/
+static gboolean gok_main_idle_input (gpointer data)
+{
+    if (gok_motion_event.n_axes != 0) {
+	gok_scanner_input_motion (gok_motion_event.axes, gok_motion_event.n_axes);
+    }
+    input_idle_handler = 0;
+    return FALSE;
+}
+
+void
+gok_main_queue_input_event (int *motion_data, gint n_axes)
+{
+    if (gok_motion_event.axes)
+	g_free (gok_motion_event.axes);
+    gok_motion_event.axes = g_new (int, n_axes);
+    gok_motion_event.n_axes = n_axes;
+    memcpy (gok_motion_event.axes, motion_data, n_axes * sizeof (int));
+    if (input_idle_handler == 0) {
+	input_idle_handler = g_idle_add (gok_main_idle_input, NULL);
+    }
+}
+
 
 /**
 * gok_main_motion_listener
@@ -1105,6 +1144,9 @@
 * @timestamp: long int, ignored
 *
 * This handler is called each time there is a motion event from the connected input device.
+* We queue the input event for processing during idle, as the rate of input events
+* may exceed our ability to process them, otherwise, and we only need to consider the most
+* recent motion event.
 */
 void gok_main_motion_listener (gint n_axes, int *motion_data, long mods, long timestamp)
 {
@@ -1118,7 +1160,10 @@
 			mods, timestamp);
 		gok_log_leave ();
 #endif
-		gok_scanner_input_motion (motion_data, n_axes);
+		if (queue_input_events)
+		    gok_main_queue_input_event (motion_data, n_axes);
+		else
+		    gok_scanner_input_motion (motion_data, n_axes); 
 
 		if (gok_data_get_drive_corepointer ()) {
 			Display *display;
@@ -2498,6 +2543,9 @@
 
 	GokKeyboard* pKeyboard;
 	GokKeyboard* pKeyboardTemp;
+
+	/* get rid of input idle handler */
+	if (input_idle_handler) g_source_remove (input_idle_handler);
 
 	/* restore the corepointer, if it was changed... */
 	gok_input_restore_corepointer ();
