From 0d72bbd16be17e52ae1b1146f550081fb9d1c01b Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Magnus=20Vigerl=C3=B6f?= Date: Thu, 10 Jan 2008 23:32:43 +0100 Subject: [PATCH] dix: Add scaling to absolute reporting with missing x&y If GetPointerEvents is called without x and/or y axis in absolute mode the core values should be scaled to the device coordinate space if they are used. --- dix/getevents.c | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index d26f103..f8f93ce 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -575,20 +575,39 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, x = valuators[0]; } else { - if (pDev->coreEvents) - x = cp->valuator->lastx; - else - x = pDev->valuator->lastx; + /* If we're sending core events but didn't provide a value, + * translate the core value (but use the device coord if + * it translates to the same coord to preserve sub-pixel + * coord information). If we're not sending core events use + * whatever value we have */ + x = pDev->valuator->lastx; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) { + 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; + } + else + x = cp->valuator->lastx; + } } if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { y = valuators[1 - first_valuator]; } else { - if (pDev->coreEvents) - y = cp->valuator->lasty; - else - y = pDev->valuator->lasty; + y = pDev->valuator->lasty; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[1].min_value; + int max = pDev->valuator->axes[1].max_value; + if(min < max) { + 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; + } + else + y = cp->valuator->lasty; + } } /* Clip both x and y to the defined limits (usually co-ord space limit). */ -- 1.5.2.5