If a button action property is currently referenced by the driver, refuse the deletion of it. Clients must unref the property first before they can delete the property.
Signed-off-by: Peter Hutterer <[email protected]> --- src/wcmXCommand.c | 21 +++++++++++++++++++++ src/xf86Wacom.c | 2 +- src/xf86Wacom.h | 1 + 3 files changed, 23 insertions(+), 1 deletions(-) diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index b197a62..1b36280 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -557,6 +557,27 @@ static int wcmSetStripProperty(DeviceIntPtr dev, Atom property, return wcmSetWheelOrStripProperty(dev, property, prop, checkonly, &wsup); } +/** + * Only allow deletion of a property if it is not being used by any of the + * button actions. + */ +int wcmDeleteProperty(DeviceIntPtr dev, Atom property) +{ + InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate; + WacomDevicePtr priv = (WacomDevicePtr) pInfo->private; + int i; + + i = wcmFindProp(property, priv->btn_actions, ARRAY_SIZE(priv->btn_actions)); + if (i < 0) + i = wcmFindProp(property, priv->wheel_actions, + ARRAY_SIZE(priv->wheel_actions)); + if (i < 0) + i = wcmFindProp(property, priv->strip_actions, + ARRAY_SIZE(priv->strip_actions)); + + return (i >= 0) ? BadAccess : Success; +} + int wcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly) { diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c index d5029f8..5d71687 100644 --- a/src/xf86Wacom.c +++ b/src/xf86Wacom.c @@ -654,7 +654,7 @@ static int wcmDevInit(DeviceIntPtr pWcm) } InitWcmDeviceProperties(pInfo); - XIRegisterPropertyHandler(pInfo->dev, wcmSetProperty, NULL, NULL); + XIRegisterPropertyHandler(pInfo->dev, wcmSetProperty, NULL, wcmDeleteProperty); return TRUE; } diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h index e22163a..dbd741c 100644 --- a/src/xf86Wacom.h +++ b/src/xf86Wacom.h @@ -174,6 +174,7 @@ extern int wcmGetPhyDeviceID(WacomDevicePtr priv); /* device properties */ extern int wcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly); +extern int wcmDeleteProperty(DeviceIntPtr dev, Atom property); extern void InitWcmDeviceProperties(InputInfoPtr pInfo); /* Utility functions */ -- 1.7.3.2 ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
