summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2012-04-02 17:05:43 -0700
committerJason Gerecke <killertofu@gmail.com>2012-08-02 09:12:24 -0700
commit089a397e5a32aa2e8e212a2c908c7ac782f2b398 (patch)
tree9f0865be855e5ef2c8e4eba7dad182f627c9de55
parent8c1f585446f56303058840fc40c133c0bab9cc7c (diff)
downloadxf86-input-wacom-089a397e5a32aa2e8e212a2c908c7ac782f2b398.tar.gz
Reset-on-None for Actions property
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 <killertofu@gmail.com>
-rw-r--r--src/wcmXCommand.c37
-rw-r--r--tools/xsetwacom.c31
2 files changed, 54 insertions, 14 deletions
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 14a3628..49a336d 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -506,6 +506,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]);
}
@@ -825,6 +843,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 3a82b16..aac8b7d 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);