This patch adds the ability to reset an individual Action by setting the corresponding element of an Actions property to the 'None' atom (i.e. 0). When encountered, the None will be replaced with an atom representing the default Action. This will let the driver behave as it currently does once raw button support is removed.
Signed-off-by: Jason Gerecke <killert...@gmail.com> --- src/wcmXCommand.c | 37 +++++++++++++++++++++++++++++++++++++ tools/xsetwacom.c | 31 +++++++++++++++++-------------- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 59ea965..80bf29a 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -502,6 +502,24 @@ static int wcmSetActionsProperty(DeviceIntPtr dev, Atom property, Atom subproperty = ((Atom*)prop->data)[i]; XIPropertyValuePtr subprop; + if (subproperty == 0) + { /* Interpret 'None' as meaning 'reset' */ + if (property == prop_btnactions) + { + if (i < 3) + wcmResetButtonAction(pInfo, i, size); + else if (i > 6) + wcmResetButtonAction(pInfo, i-4, size); + } + else if (property == prop_strip_buttons) + wcmResetStripAction(pInfo, i); + else if (property == prop_wheel_buttons) + wcmResetWheelAction(pInfo, i); + + if (subproperty != handlers[i]) + subproperty = handlers[i]; + } + XIGetDeviceProperty(dev, subproperty, &subprop); wcmSetActionProperty(dev, subproperty, subprop, checkonly, &handlers[i], &actions[i]); } @@ -821,6 +839,25 @@ int wcmGetProperty (DeviceIntPtr dev, Atom property) PropModeReplace, 5, values, FALSE); } + else if (property == prop_btnactions) + { + int nbuttons = min(max(priv->nbuttons + 4, 7), WCM_MAX_BUTTONS); + return XIChangeDeviceProperty(dev, property, XA_ATOM, 32, + PropModeReplace, nbuttons, + priv->btn_actions, FALSE); + } + else if (property == prop_strip_buttons) + { + return XIChangeDeviceProperty(dev, property, XA_ATOM, 32, + PropModeReplace, ARRAY_SIZE(priv->strip_actions), + priv->strip_actions, FALSE); + } + else if (property == prop_wheel_buttons) + { + return XIChangeDeviceProperty(dev, property, XA_ATOM, 32, + PropModeReplace, ARRAY_SIZE(priv->wheel_actions), + priv->wheel_actions, FALSE); + } return Success; } diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 28332d1..56ffa05 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1216,9 +1216,10 @@ static Bool parse_actions(Display *dpy, int argc, char **argv, unsigned long* da * the driver can understand. * * Once we have a list of actions, we can store it in the appropriate - * child property. If none exists, we must first create one and update - * the parent list. If we want no action to occur, we can delete the - * child property and have the parent point to '0' instead. + * child property. Action atoms should be pre-created by the server, + * so it is an error if one does not exist. To reset the action to its + * default, we can have the parent point to '0' (which is a special + * signal to the Wacom driver). * * @param dpy X display we want to query * @param dev X device we want to modify @@ -1259,16 +1260,20 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i /* set or unset the property */ prop = btnact_data[offset]; - if (nitems > 0) - { /* Setting a new or existing property */ - if (!prop) - { - char buff[64]; - sprintf(buff, "%s action %d", XGetAtomName(dpy, btnact_prop), (offset + 1)); - prop = XInternAtom(dpy, buff, False); - btnact_data[offset] = prop; - } + if (!prop) + { + /* The subproperty at the given offset is set to 'None', + * meaning the device does not support its meaning. E.g. + * buttons 4-7 are 'None' since the device doesn't have + * physical buttons relating to them. + */ + fprintf(stderr, "Unsupported offset into '%s' property.\n", + XGetAtomName(dpy, btnact_prop)); + goto out; + } + if (nitems > 0) + { /* Setting an existing property */ /* FIXME: the property containing the key sequence must be * set before updating the button action properties */ XChangeDeviceProperty(dpy, dev, prop, XA_INTEGER, 32, @@ -1288,8 +1293,6 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i PropModeReplace, (unsigned char*)btnact_data, btnact_nitems); - - XDeleteDeviceProperty(dpy, dev, prop); } XFlush(dpy); -- 1.7.9.5 ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel