[PATCH] dix: fix calculation of valuator events.

Peter Hutterer peter.hutterer at who-t.net
Thu Dec 4 17:12:36 PST 2008


On Thu, Dec 04, 2008 at 04:56:09PM -0800, Keith Packard wrote:
> On Fri, 2008-12-05 at 10:45 +1000, Peter Hutterer wrote:
> 
> >      if (num_valuators) {
> > -        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
> > +        if (((num_valuators - 1) / 6) + 1 > MAX_VALUATOR_EVENTS)
> >              num_valuators = MAX_VALUATOR_EVENTS;
> 
> This still looks wrong to me; why would you assign MAX_VALUATOR_EVENTS t
> num_valuators? (no, I haven't looked at the surrounding code, just this
> patch).

whoops. thanks, I missed that.

>From 1b79036fd2a5724c2b31892b564927c009b8b7a0 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at redhat.com>
Date: Fri, 5 Dec 2008 10:12:57 +1000
Subject: [PATCH] dix: fix calculation of valuator events.

Follow-up to 4971315296cb. countValuatorEvents was copied from GKVE where it
was obviously broken but nobody noticed. GPE had the correct version, but that
one got lost during de-duplication. Restoring the correct calculation - if we
have 6 valuators, we want 1 valuator event, not 2.

Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
---
 dix/getevents.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 82be5e9..9592d4c 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -728,9 +728,9 @@ static int
 countValuatorEvents(int num_valuators)
 {
     if (num_valuators) {
-        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        return (num_valuators / 6) + 1;
+        if (((num_valuators - 1) / 6) + 1 > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS * 6;
+        return ((num_valuators - 1)/ 6) + 1;
     } else
         return 0;
 }
-- 
1.6.0.4

Cheers,
  Peter



More information about the xorg mailing list