summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-02-03 19:15:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-02-04 15:24:21 +1000
commit7e92aca68a666499c7d6f1946cc849cfb5653ae0 (patch)
treef42e2e9b073214a231cbc67b232c4e477e202e00
parentb6fd73d4f79b4731caee4dc72e9f6fcecd2b5161 (diff)
Initialize button action properties for the correct button number (#45557)
Previous code had the number of properties for button actions hardcoded to 16 (WCM_MAX_MOUSE_BUTTONS). Drop that define and instead initialize the same number of properties that we have on the device as well. X.Org Bug 45557 <http://bugs.freedesktop.org/show_bug.cgi?id=45557> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
-rw-r--r--src/wcmXCommand.c29
-rw-r--r--src/xf86WacomDefs.h7
2 files changed, 17 insertions, 19 deletions
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 6613a59..d0963f1 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -122,9 +122,9 @@ static Atom InitWcmAtom(DeviceIntPtr dev, char *name, Atom type, int format, int
{
int i;
Atom atom;
- uint8_t val_8[WCM_MAX_MOUSE_BUTTONS];
- uint16_t val_16[WCM_MAX_MOUSE_BUTTONS];
- uint32_t val_32[WCM_MAX_MOUSE_BUTTONS];
+ uint8_t val_8[WCM_MAX_BUTTONS];
+ uint16_t val_16[WCM_MAX_BUTTONS];
+ uint32_t val_32[WCM_MAX_BUTTONS];
pointer converted = val_32;
for (i = 0; i < nvalues; i++)
@@ -156,7 +156,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
{
WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
WacomCommonPtr common = priv->common;
- int values[WCM_MAX_MOUSE_BUTTONS];
+ int values[WCM_MAX_BUTTONS];
+ int nbuttons;
DBG(10, priv, "\n");
@@ -225,9 +226,11 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
values[0] = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
prop_tooltype = InitWcmAtom(pInfo->dev, WACOM_PROP_TOOL_TYPE, XA_ATOM, 32, 1, values);
+
/* default to no actions */
+ nbuttons = min(max(priv->nbuttons + 4, 7), WCM_MAX_BUTTONS);
memset(values, 0, sizeof(values));
- prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, XA_ATOM, 32, WCM_MAX_MOUSE_BUTTONS, values);
+ prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, XA_ATOM, 32, nbuttons, values);
if (IsPad(priv)) {
memset(values, 0, sizeof(values));
@@ -288,7 +291,7 @@ static int wcmSanityCheckProperty(XIPropertyValuePtr prop)
case AC_KEY:
break;
case AC_BUTTON:
- if (code > WCM_MAX_MOUSE_BUTTONS)
+ if (code > WCM_MAX_BUTTONS)
return BadValue;
break;
case AC_DISPLAYTOGGLE:
@@ -492,12 +495,12 @@ static int wcmSetWheelOrStripProperty(DeviceIntPtr dev, Atom property,
switch (prop->format)
{
case 8:
- if (values.v8[0] > WCM_MAX_MOUSE_BUTTONS ||
- values.v8[1] > WCM_MAX_MOUSE_BUTTONS ||
- values.v8[2] > WCM_MAX_MOUSE_BUTTONS ||
- values.v8[3] > WCM_MAX_MOUSE_BUTTONS ||
- values.v8[4] > WCM_MAX_MOUSE_BUTTONS ||
- values.v8[5] > WCM_MAX_MOUSE_BUTTONS)
+ if (values.v8[0] > WCM_MAX_BUTTONS ||
+ values.v8[1] > WCM_MAX_BUTTONS ||
+ values.v8[2] > WCM_MAX_BUTTONS ||
+ values.v8[3] > WCM_MAX_BUTTONS ||
+ values.v8[4] > WCM_MAX_BUTTONS ||
+ values.v8[5] > WCM_MAX_BUTTONS)
return BadValue;
if (!checkonly) {
@@ -846,7 +849,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
#endif
} else if (property == prop_btnactions)
{
- if (prop->size != WCM_MAX_MOUSE_BUTTONS)
+ if (prop->size != WCM_MAX_BUTTONS)
return BadMatch;
wcmSetPropertyButtonActions(dev, property, prop, checkonly);
} else
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index 3b79189..167866a 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -188,12 +188,7 @@ struct _WacomModel
#define DEFAULT_THRESHOLD (FILTER_PRESSURE_RES / 75)
#define WCM_MAX_BUTTONS 32 /* maximum number of tablet buttons */
-#define WCM_MAX_MOUSE_BUTTONS 16 /* maximum number of buttons-on-pointer
- * (which are treated as mouse buttons,
- * not as keys like tablet menu buttons).
- * For backward compability support,
- * tablet buttons besides the strips are
- * treated as buttons */
+
#define AXIS_INVERT 0x01 /* Flag describing an axis which increases "downward" */
#define AXIS_BITWISE 0x02 /* Flag describing an axis which changes bitwise */