[PATCH] mi: ensure chained button mappings from SD -> MD (#19282)

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 8 14:17:46 PST 2009


On Thu, Jan 08, 2009 at 11:19:15AM -0500, Thomas Jaeger wrote:
> Peter Hutterer wrote:
> > On Thu, Jan 08, 2009 at 01:43:39AM -0500, Thomas Jaeger wrote:
> >> Alexia: What is the point of remapping buttons willy-nilly before
> >> posting an event anyway?  The comment suggests it just servers as a
> >> reminder of how remapping works.  It's problematic in that proper
> >> DeviceMappingNotify events aren't send and I don't want to think about
> >> what could potentially happen if some client calls XTestFakeButtonEvent
> >> (let alone XTestFakeDeviceButtonEvent) at the right moment.  The problem
> >> in bug #19282 was fixed in ubuntu by simply skipping the remapping step,
> >> and I'm not aware of any issues that this may have caused.
> > 
> > Button maps aren't copied from SDs to MDs, so they are persistent on both
> > devices. Which means with chained button mapping, you can configure an MD to
> > be left-handed (i.e. 321 button mapping) and any SD attached to this MD will
> > assume this mapping. If one SD needs additional mapping (e.g. 2->3), then this
> > can be achieved by just remapping this single device.
> 
> This is okay.
> 
> > Since the mapping stays fixed for each device, there are no
> > DeviceMappingNotify events that need to be sent.
> 
> The wacom driver changes button mappings on the fly by simply writing
> into the device's button map instead of going the SetButtonMapping
> route.  Yesterday, I thought that this was completely random, but it
> actually tries to copy the mapping that is set up via the xsetwacom
> tool.  

that's not good. I think there's historical reason to do so, but by now the
drivers should just let button mapping to the DIX (unless they need something
really special). xsetwacom would be better off using libXi's
XSetDeviceButtonMapping.

> It doesn't do so correctly, though, shifting the entries by one.
>  So it maps button 0 to button 1 and then sends a button 0 press.  It's
> kind of amazing that this even works.  Maybe there should be a check in
> the X server that rejects such invalid events.

IIRC the X server rejects button 0 presses. Though not immediately I admit,
it's somewhere hidden in the event processing. something like this should be in order:

diff --git a/dix/getevents.c b/dix/getevents.c
index d9a2ce5..96cf2f5 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -989,6 +989,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int t
         ((num_valuators + first_valuator) > pDev->valuator->numAxes) ||
         (type != MotionNotify && type != ButtonPress && type != ButtonRelease) 
         (type != MotionNotify && !pDev->button) ||
+        ((type == ButtonPress || type == ButtonRelease) && !buttons) ||
         (type == MotionNotify && num_valuators <= 0))
         return 0;
 
> Ping: I can write up a patch.  Is there a public linuxwacom repo anywhere?

linuxwacom.sourceforge.net is the closest thing to it.

Cheers,
  Peter



More information about the xorg mailing list