On Thu, Dec 17, 2009 at 04:52:27PM -0800, Ping wrote: > Hope you didn't use the suggestion I made earlier. Attached is the patch > that fixes the issue properly.
thanks, I haven't found a good way around it yet myself but the approach looks good. see below for comments > I added a few comments in the code and hopefully they made it clear for what > I did. Feel free to add commit comments as you see appropriate. Or shout > back if you need more details. > > Ping > > P.S. any progress in resolving the wcmTouch set to 0 after resume issue? haven't had any time for it yet, sorry. stuff keeps piling up here. > From c6cd83e7197e952dfa6fbe5623e9d2a8c682b26a Mon Sep 17 00:00:00 2001 > From: Ping Cheng <[email protected]> > Date: Thu, 17 Dec 2009 16:41:22 -0800 > Subject: [PATCH] Fix tablet area property check issue > > Signed-off-by: Ping Cheng <[email protected]> > --- > src/wcmXCommand.c | 42 ++++++++++++++++-------------------------- > 1 files changed, 16 insertions(+), 26 deletions(-) > > diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c > index 2ac7eed..a427ad0 100644 > --- a/src/wcmXCommand.c > +++ b/src/wcmXCommand.c > @@ -307,46 +307,36 @@ int xf86WcmSetProperty(DeviceIntPtr dev, Atom property, > XIPropertyValuePtr prop, > if (property == prop_tablet_area) > { > INT32 *values = (INT32*)prop->data; > - WacomToolArea area; > + WacomToolAreaPtr area = priv->toolarea; > > if (prop->size != 4 || prop->format != 32) > return BadValue; > > - area.topX = values[0]; > - area.topY = values[1]; > - area.bottomX = values[2]; > - area.bottomY = values[3]; > - > - /* FIXME: this will always be the case? */ > - if (WcmAreaListOverlap(&area, priv->tool->arealist)) > - return BadValue; > - > if (!checkonly) > { > - /* Invalid range resets axis to defaults */ > - if (values[0] >= values[2]) > - { > - values[0] = 0; > - if (!IsTouch(priv)) > - values[2] = common->wcmMaxX; > - else > - values[2] = common->wcmMaxTouchX; > - } > + /* validate the values first */ > + if ((values[0] >= values[2]) || (values[1] >= values[3])) > + return BadValue; principle looks good, but we can't do it that way. BadValue must be returned only during checkonly == TRUE so the check needs to be moved out. Likewise, a property handler must not modify any data unless checkonly is true. the reason for this is that you may have multiple property handler on a given property. the server first asks all of them whether the change is possible, then applies the change. If any handler returns BadValue during the checkonly phase, the property handler returns that to the client. it's a sort-of atomic approach, either all prop handlers succeed or none of them. also, by removing the if (values[0] >= values[2]) check, we lose the ability to reset the area to the defaults (xsetwacom set xydefaults), that should be kept in there as behaviour. I think this patch should work though if you just backup priv->toolarea, change it, and then set it back to the previous value after all the checks have passed or succeeded. or - even better - copy the arealist as a whole and check only on the copy. that way we don't modify the device during checkonly at all. the principle is definitely sound though. Cheers, Peter > > - if (values[1] >= values[3]) > + area->topX = values[0]; > + area->topY = values[1]; > + area->bottomX = values[2]; > + area->bottomY = values[3]; > + > + if (WcmAreaListOverlap(area, priv->tool->arealist)) > { > - values[1] = 0; > - if (!IsTouch(priv)) > - values[3] = common->wcmMaxY; > - else > - values[3] = common->wcmMaxTouchY; > + /* reset area back to the original values */ > + area->topX = priv->topX; > + area->topY = priv->topY; > + area->bottomX = priv->bottomX; > + area->bottomY = priv->bottomY; > + return BadValue; > } > > priv->topX = values[0]; > priv->topY = values[1]; > priv->bottomX = values[2]; > priv->bottomY = values[3]; > - xf86WcmMappingFactor(local); > xf86WcmInitialCoordinates(local, 0); > xf86WcmInitialCoordinates(local, 1); > } > -- > 1.6.5.2 ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
