[PATCH 13/27] Input: Convert transformAbsolute to work on doubles

Daniel Stone daniel at fooishbar.org
Fri Jun 3 07:59:49 PDT 2011


Change transformAbsolute to use doubles internally, and to set the value
in the mask if it was transformed at all.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 dix/getevents.c |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 2afe1a1..182f2d9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1039,14 +1039,26 @@ FreeEventList(InternalEvent *list, int num_events)
 }
 
 static void
-transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
+transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 {
-    struct pixman_f_vector p = {.v = {*x, *y, 1}};
-
-    pixman_f_transform_point(&dev->transform, &p);
-
-    *x = lround(p.v[0]);
-    *y = lround(p.v[1]);
+    struct pixman_f_vector pi, po;
+
+    /* p' = M * p in homogeneous coordinates */
+    pi.v[0] = (valuator_mask_isset(mask, 0) ?
+               valuator_mask_get_double(mask, 0) :
+               dev->last.valuators[0]);
+    pi.v[1] = (valuator_mask_isset(mask, 1) ?
+               valuator_mask_get_double(mask, 1) :
+               dev->last.valuators[1]);
+    pi.v[2] = 1.0;
+    memcpy(&po, &pi, sizeof(po));
+
+    pixman_f_transform_point(&dev->transform, &po);
+
+    if (pi.v[0] != po.v[0])
+        valuator_mask_set_double(mask, 0, po.v[0]);
+    if (pi.v[1] != po.v[1])
+        valuator_mask_set_double(mask, 1, po.v[1]);
 }
 
 /**
@@ -1162,16 +1174,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
             }
         }
 
-        x = (valuator_mask_isset(&mask, 0) ? valuator_mask_get(&mask, 0) :
-             pDev->last.valuators[0]);
-        y = (valuator_mask_isset(&mask, 1) ? valuator_mask_get(&mask, 1) :
-             pDev->last.valuators[1]);
-        transformAbsolute(pDev, &mask, &x, &y);
-        if (valuator_mask_isset(&mask, 0))
-            valuator_mask_set(&mask, 0, x);
-        if (valuator_mask_isset(&mask, 1))
-            valuator_mask_set(&mask, 1, y);
-
+        transformAbsolute(pDev, &mask);
+        /* x and y are only set, but not used, by moveAbsolute */
         moveAbsolute(pDev, &x, &y, &mask);
     } else {
         if (flags & POINTER_ACCELERATE) {
-- 
1.7.5.3



More information about the xorg-devel mailing list