diff -Nur xfree86-driver-synaptics-0.99.3.orig/src/synaptics.c xfree86-driver-synaptics-0.99.3/src/synaptics.c --- xfree86-driver-synaptics-0.99.3.orig/src/synaptics.c 2008-12-15 00:33:15.000000000 +0100 +++ xfree86-driver-synaptics-0.99.3/src/synaptics.c 2009-04-21 16:53:56.000000000 +0200 @@ -124,6 +124,9 @@ static Bool QueryHardware(LocalDevicePtr); static void ReadDevDimensions(LocalDevicePtr); +int oldTimeMillis =0; +Bool wasTimeSkipped = FALSE; + #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3 void InitDeviceProperties(LocalDevicePtr local); int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, @@ -1538,6 +1541,57 @@ dy += hw->guest_dy; } + /* See if movements are too quick to take + place in few milliseconds + */ + if (dx || dy) { + int oldMillis = priv->move_hist[priv->hist_index].millis; + int oldX = priv->move_hist[priv->hist_index].x; + int oldY = priv->move_hist[priv->hist_index].y; + int elapsed_time = hw->millis - oldMillis; + int dX = abs(abs(hw->x) - abs(oldX)); + int dY = abs(abs(hw->y) - abs(oldY)); + double threshold = 90.0; + + /* + xf86Msg(X_INFO, "\nx=%d, y=%d, millis=%d, oldmillis=%d, + realoldmillis=%d, Ax=%d Ay=%d dx=%f dy=%f dtime=%d\n", + hw->x, hw->y, hw->millis, oldMillis, oldTimeMillis, dX, + dY, dx, dy, elapsed_time); + */ + /* Ignore deltas as they couldn't possibly happen in so little time */ + if (elapsed_time <= 20 && (abs(dx) >= threshold || abs(dy) >= threshold)) { + dx = 0.0; + dy = 0.0; + wasTimeSkipped = FALSE; + } + /* A comparison between the timestamp in priv->move_hist and hw->millis shows + * that something went wrong and that an event was skipped, hence these + * deltas are wrong. + * Let's ignore the deltas and set wasTimeSkipped to TRUE as the next deltas + * will be wrong too. + */ + else if (oldTimeMillis > 0 && (oldMillis != oldTimeMillis)) { + dx = 0.0; + dy = 0.0; + wasTimeSkipped = TRUE; + } + /* Something went wrong and an event was previously skipped, hence these deltas + * are wrong. + * Let's ignore the deltas and set wasTimeSkipped to FALSE as the next deltas + * should be good. + */ + else { + if (wasTimeSkipped) { + dx = 0.0; + dy = 0.0; + } + wasTimeSkipped = FALSE; + } + oldTimeMillis = hw->millis; + + } + *dxP = dx; *dyP = dy;