xserver: Branch 'mpx'

Peter Hutterer whot at kemper.freedesktop.org
Tue Jan 8 23:26:29 PST 2008


 Xi/exevents.c      |   29 ++++++++++++++++++++++-------
 dix/devices.c      |    2 +-
 include/inputstr.h |    2 +-
 3 files changed, 24 insertions(+), 9 deletions(-)

New commits:
commit 4e85c7c322faf14c14e4229fa294b8e3d3a4d304
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Jan 9 17:36:39 2008 +1030

    Xi: keep a counter of buttons down to avoid duplicate press/release events.
    
    If two devices are attached to the same master device, pressing button 1 on
    each of them leads to two button presses from the same device. Some apps
    really don't like that.
    
    So we just put a counter in place and only send the first press and the last
    release.

diff --git a/Xi/exevents.c b/Xi/exevents.c
index e577e3b..fa39565 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -348,13 +348,28 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
     }
 
     ALLOC_COPY_CLASS_IF(button, ButtonClassRec);
-#ifdef XKB
     if (to->button)
     {
+        int i;
+        DeviceIntPtr sd;
+
+        memset(to->button, 0, MAP_LENGTH);
+        /* merge button states from all attached devices */
+        for (sd = inputInfo.devices; sd; sd = sd->next)
+        {
+            if (sd->isMaster || sd->u.master != to)
+                continue;
+
+            for (i = 0; i < MAP_LENGTH; i++)
+            {
+                to->button->down[i] += sd->button->down[i];
+            }
+        }
+#ifdef XKB
         to->button->xkb_acts = NULL;
         /* XXX: XkbAction needs to be copied */
-    }
 #endif
+    }
     ALLOC_COPY_CLASS_IF(focus, FocusClassRec);
     ALLOC_COPY_CLASS_IF(proximity, ProximityClassRec);
     ALLOC_COPY_CLASS_IF(absolute, AbsoluteClassRec);
@@ -541,8 +556,8 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
         if (!b)
             return DONT_PROCESS;
 
-	kptr = &b->down[key >> 3];
-	*kptr |= bit;
+        if (b->down[key]++ > 0)
+            return DONT_PROCESS;
 	if (device->valuator)
 	    device->valuator->motionHintWindow = NullWindow;
         b->buttonsDown++;
@@ -556,10 +571,10 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
         if (!b)
             return DONT_PROCESS;
 
-	kptr = &b->down[key >> 3];
-        if (!(*kptr & bit))
+        if (b->down[key] == 0)
+            return DONT_PROCESS;
+        if (--b->down[key] > 0)
             return DONT_PROCESS;
-	*kptr &= ~bit;
 	if (device->valuator)
 	    device->valuator->motionHintWindow = NullWindow;
         if (b->buttonsDown >= 1 && !--b->buttonsDown)
diff --git a/dix/devices.c b/dix/devices.c
index 74212b2..a784637 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1178,7 +1178,7 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons,
     butc->buttonsDown = 0;
     butc->state = 0;
     butc->motionMask = 0;
-    bzero((char *)butc->down, DOWN_LENGTH);
+    bzero((char *)butc->down, MAP_LENGTH);
 #ifdef XKB
     butc->xkb_acts=	NULL;
 #endif
diff --git a/include/inputstr.h b/include/inputstr.h
index 9011ba2..8c1d5fc 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -184,7 +184,7 @@ typedef struct _ButtonClassRec {
     CARD8		buttonsDown;	/* number of buttons currently down */
     unsigned short	state;
     Mask		motionMask;
-    CARD8		down[DOWN_LENGTH];
+    CARD8		down[MAP_LENGTH];
     CARD8		map[MAP_LENGTH];
 #ifdef XKB
     union _XkbAction    *xkb_acts;


More information about the xorg-commit mailing list