+static gboolean
+spi_dec_poll_mouse_moved (gpointer data)
+{
+ SpiRegistry *registry = SPI_REGISTRY (data);
+ CORBA_Environment ev;
+ Accessibility_Event e;
+ Window root_return, child_return;
+ int win_x_return,win_y_return;
+ int x, y;
+ unsigned int mask_return;
+ Display *display = spi_get_display ();
+ if (last_mouse_pos == NULL) {
+ last_mouse_pos = g_new0 (GdkPoint, 1);
+ last_mouse_pos->x = 0;
+ last_mouse_pos->y = 0;
+ e.type = g_strdup ("mouse:abs");
+ } else {
+ e.type = g_strdup ("mouse:rel");
+ }
+ if (display != NULL)
+ XQueryPointer(display, DefaultRootWindow (display),
+ &root_return, &child_return,
+ &x, &y,
+ &win_x_return, &win_y_return, &mask_return);
+ if (x != last_mouse_pos->x || y != last_mouse_pos->y) {
+ e.source = BONOBO_OBJREF (registry->desktop);
+ e.detail1 = x - last_mouse_pos->x;
+ e.detail2 = y - last_mouse_pos->y;
+ CORBA_exception_init (&ev);
+ last_mouse_pos->x = x;
+ last_mouse_pos->y = y;
+ Accessibility_Registry_notifyEvent (BONOBO_OBJREF (registry),
+ &e,
+ &ev);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
+spi_dec_poll_mouse_idle (gpointer data)
+{
+ if (! spi_dec_poll_mouse_moved (data))
+ return TRUE;
+ else
+ {
+ g_timeout_add (20, spi_dec_poll_mouse_moving, data);
+ return FALSE;
+ }
+}
+
+static gboolean
+spi_dec_poll_mouse_moving (gpointer data)
+{
+ if (spi_dec_poll_mouse_moved (data))
+ return TRUE;
+ else
+ {
+ g_timeout_add (100, spi_dec_poll_mouse_idle, data);
+ return FALSE;
+ }
+}
+
+static void
+spi_dec_init_mouse_listener (SpiRegistry *registry)
+{
+ g_timeout_add (100, spi_dec_poll_mouse_idle, registry);
+}
+