From f6e972adbe79f97e884534db544bdf2a9d83c8e7 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Magnus=20Vigerl=C3=B6f?= Date: Tue, 8 Jan 2008 21:54:42 +0100 Subject: [PATCH] dix: Allow arbitrary value ranges in GetPointerEvents Don't use a positive value as a marker for if a max-value is defined on the valuators. Use the existence of a valid value range instead. This will also make it possible to define arbitrary start and end-values for min and max as long as min < max. --- dix/getevents.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index 10cba16..94b9f50 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -308,10 +308,13 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val) { AxisInfoPtr axes = pDev->valuator->axes + axisNum; - if (*val < axes->min_value) - *val = axes->min_value; - if (axes->max_value >= 0 && *val > axes->max_value) - *val = axes->max_value; + /* No clipping if the value-range <= 0 */ + if(axes->min_value < axes->min_value) { + if (*val < axes->min_value) + *val = axes->min_value; + if (*val > axes->max_value) + *val = axes->max_value; + } } /** @@ -604,7 +607,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, * pixel movements from the device. */ int min = pDev->valuator->axes[0].min_value; int max = pDev->valuator->axes[0].max_value; - if(max > 0) { + if(min < max) { x = pDev->valuator->lastx; if((int)((float)(x-min)*scr->width/(max-min+1)) != cp->valuator->lastx) x = (int)((float)(cp->valuator->lastx)*(max-min+1)/scr->width)+min; @@ -614,7 +617,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, min = pDev->valuator->axes[1].min_value; max = pDev->valuator->axes[1].max_value; - if(max > 0) { + if(min < max) { y = pDev->valuator->lasty; if((int)((float)(y-min)*scr->height/(max-min+1)) != cp->valuator->lasty) y = (int)((float)(cp->valuator->lasty)*(max-min+1)/scr->height)+min; @@ -653,11 +656,11 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, * sending core events */ if (pDev->coreEvents) { AxisInfoPtr ax = pDev->valuator->axes; - if(ax[0].max_value > 0) + if(ax[0].min_value < ax[0].max_value) x = (int)((float)(x-ax[0].min_value)*scr->width/ (ax[0].max_value-ax[0].min_value+1)); cp->valuator->lastx = x; - if(ax[1].max_value > 0) + if(ax[1].min_value < ax[1].max_value) y = (int)((float)(y-ax[1].min_value)*scr->height/ (ax[1].max_value-ax[1].min_value+1)); cp->valuator->lasty = y; @@ -674,14 +677,14 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, if(x != cp->valuator->lastx) { AxisInfoPtr ax = &pDev->valuator->axes[0]; cp->valuator->lastx = pDev->valuator->lastx = x; - if(ax->max_value > 0) + if(ax->min_value < ax->max_value) pDev->valuator->lastx = (int)((float)(x)*(ax->max_value-ax->min_value+1)/ scr->height)+ax->min_value; } if(y != cp->valuator->lasty) { AxisInfoPtr ax = &pDev->valuator->axes[1]; cp->valuator->lasty = pDev->valuator->lasty = y; - if(ax->max_value > 0) + if(ax->min_value < ax->max_value) pDev->valuator->lasty = (int)((float)(y)*(ax->max_value-ax->min_value+1)/ scr->height)+ax->min_value; } -- 1.5.2.5