diff options
author | Ping Cheng <pingc@wacom.com> | 2009-12-21 16:52:28 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-12-22 14:01:47 +1000 |
commit | a2f89b40e54e2abc854af42453160488ff22499f (patch) | |
tree | fe09c5dac0578f0f1da81d87cdb7d4acd7d8c03d | |
parent | 781bb48a2ccfb2f6c12f53bc93f5a123af65bc26 (diff) | |
download | xf86-input-wacom-a2f89b40e54e2abc854af42453160488ff22499f.tar.gz |
Remove area overlap check for area property
Temporarily change the area to the new coordinates, do the range overlap
check and then change it back to the original. This is needed since
otherwise the area overlap check always fails (since the new area will be
mostly identical to the current one).
New behaviour: all four coordinates set to -1 reset the area to the
defaults.
Signed-off-by: Ping Cheng <pinglinux@gmail.com>
-rw-r--r-- | src/wcmXCommand.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 59c64a9..7b40685 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -304,45 +304,54 @@ 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]; + /* value validation is unnecessary since we let utility programs, such as + * xsetwacom and userland control panel take care of the validation role. + * when all four values are set to -1, it is an area reset (xydefault) */ + if ((values[0] != -1) || (values[1] != -1) || + (values[2] != -1) || (values[3] != -1)) + { + WacomToolArea tmp_area = *area; - /* FIXME: this will always be the case? */ - if (WcmAreaListOverlap(&area, priv->tool->arealist)) - return BadValue; + area->topX = values[0]; + area->topY = values[1]; + area->bottomX = values[2]; + area->bottomY = values[3]; + + /* validate the area */ + if (WcmAreaListOverlap(area, priv->tool->arealist)) + { + *area = tmp_area; + return BadValue; + } + *area = tmp_area; + } if (!checkonly) { - /* Invalid range resets axis to defaults */ - if (values[0] >= values[2]) + if ((values[0] == -1) && (values[1] == -1) && + (values[2] == -1) && (values[3] == -1)) { values[0] = 0; - if (!IsTouch(priv)) + values[1] = 0; + if (!IsTouch(priv)) values[2] = common->wcmMaxX; - else + else values[2] = common->wcmMaxTouchX; - } - - if (values[1] >= values[3]) - { - values[1] = 0; - if (!IsTouch(priv)) + if (!IsTouch(priv)) values[3] = common->wcmMaxY; - else + else values[3] = common->wcmMaxTouchY; } - priv->topX = values[0]; - priv->topY = values[1]; - priv->bottomX = values[2]; - priv->bottomY = values[3]; + priv->topX = area->topX = values[0]; + priv->topY = area->topY = values[1]; + priv->bottomX = area->bottomX = values[2]; + priv->bottomY = area->bottomY = values[3]; xf86WcmInitialCoordinates(local, 0); xf86WcmInitialCoordinates(local, 1); } |