From 06aebecb19dd9d90d73b742a09b6068b862f1d05 Mon Sep 17 00:00:00 2001 From: Simon Thum Date: Wed, 8 Apr 2009 14:35:01 +0200 Subject: [PATCH] dix: fix pointer accelerations remainder handling This didn't really work as intended, but did amazingly well thanks to roundf() hiding the defect. Cheers! Signed-off-by: Peter Hutterer --- dix/ptrveloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index a3a04512f..fc1d1210b 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -950,7 +950,7 @@ acceleratePointerPredictable( int *px = NULL, *py = NULL; DeviceVelocityPtr velocitydata = (DeviceVelocityPtr) pDev->valuator->accelScheme.accelData; - float fdx, fdy; /* no need to init */ + float fdx, fdy, tmp; /* no need to init */ Bool soften = TRUE; if (!num_valuators || !valuators || !velocitydata) @@ -991,14 +991,14 @@ acceleratePointerPredictable( (mult > 1.0) && soften); if (dx) { - pDev->last.remainder[0] = roundf(mult * fdx + pDev->last.remainder[0]); - *px = (int)pDev->last.remainder[0]; - pDev->last.remainder[0] = pDev->last.remainder[0] - (float)*px; + tmp = mult * fdx + pDev->last.remainder[0]; + *px = (int)roundf(tmp); + pDev->last.remainder[0] = tmp - (float)*px; } if (dy) { - pDev->last.remainder[1] = roundf(mult * fdy + pDev->last.remainder[1]); - *py = (int)pDev->last.remainder[1]; - pDev->last.remainder[1] = pDev->last.remainder[1] - (float)*py; + tmp = mult * fdy + pDev->last.remainder[1]; + *py = (int)roundf(tmp); + pDev->last.remainder[1] = tmp - (float)*py; } } }