[PATCH 2/2] Handle non continuous valuator data in getValuatorEvents

Chase Douglas chase.douglas at canonical.com
Mon Mar 28 10:53:48 PDT 2011


This allows for masked valuators to be handled properly in XI 1.x
events. Any unset valuators in the device event are set to the last
known value when transmitted on the wire through XI 1.x valuator events.

Fixes https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/736500

Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 dix/eventconvert.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 9fce447..edecf6c 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -358,27 +358,30 @@ countValuators(DeviceEvent *ev, int *first)
     return num_valuators;
 }
 
-#define set_valuator_value(xv, ev, num) \
-    xv->valuator##num = (ev)->valuators.data[(xv)->first_valuator + num];
+#define set_valuator_value(xv, ev, dev, num) \
+    if (BitIsOn((ev)->valuators.mask, (xv)->first_valuator + num)) \
+        xv->valuator##num = (ev)->valuators.data[(xv)->first_valuator + num]; \
+    else \
+        xv->valuator##num = \
+            (dev)->valuator->axisVal[(xv)->first_valuator + num];
 static int
 getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
 {
     int i;
     int state = 0;
     int first_valuator, num_valuators;
+    DeviceIntPtr dev;
 
 
     num_valuators = countValuators(ev, &first_valuator);
     if (num_valuators > 0)
     {
-        DeviceIntPtr dev = NULL;
         dixLookupDevice(&dev, ev->deviceid, serverClient, DixUseAccess);
         /* State needs to be assembled BEFORE the device is updated. */
         state = (dev && dev->key) ? XkbStateFieldFromRec(&dev->key->xkbInfo->state) : 0;
         state |= (dev && dev->button) ? (dev->button->state) : 0;
     }
 
-    /* FIXME: non-continuous valuator data in internal events*/
     for (i = 0; i < num_valuators; i += 6, xv++) {
         xv->type = DeviceValuator;
         xv->first_valuator = first_valuator + i;
@@ -388,17 +391,17 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
 
         switch (xv->num_valuators) {
         case 6:
-            set_valuator_value(xv, ev, 5);
+            set_valuator_value(xv, ev, dev, 5);
         case 5:
-            set_valuator_value(xv, ev, 4);
+            set_valuator_value(xv, ev, dev, 4);
         case 4:
-            set_valuator_value(xv, ev, 3);
+            set_valuator_value(xv, ev, dev, 3);
         case 3:
-            set_valuator_value(xv, ev, 2);
+            set_valuator_value(xv, ev, dev, 2);
         case 2:
-            set_valuator_value(xv, ev, 1);
+            set_valuator_value(xv, ev, dev, 1);
         case 1:
-            set_valuator_value(xv, ev, 0);
+            set_valuator_value(xv, ev, dev, 0);
         }
 
         if (i + 6 < num_valuators)
@@ -407,7 +410,6 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
 
     return (num_valuators + 5) / 6;
 }
-#undef set_valuator_value
 
 
 static int
-- 
1.7.4.1



More information about the xorg-devel mailing list