summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2016-01-12 12:15:35 -0800
committerJason Gerecke <killertofu@gmail.com>2016-01-25 10:59:16 -0800
commite1df2c330db940c96030dafcab850fc167531113 (patch)
tree978b9326ddae0ab5d745d0b4fa086b0b62d569aa /tools
parentd9119a8c412926b97fac364d32e2bade47d2c295 (diff)
downloadxf86-input-wacom-e1df2c330db940c96030dafcab850fc167531113.tar.gz
xsetwacom: Remove unnecessary static state from 'get_actions'
The 'last_type' variable within 'get_actions' stores the type of the last action encountered. When dealing with "key" or "button" actions, we use that information to determine if we need to print out the action prefix or not (if the type hasn't changed, its safe to leave the prefix out). For some reason, this variable was marked as 'static', which causes it to retain its value across invocations. The function is only called once for any given button, meaning that we improperly retain the "last_type" across buttons. If the last action on a button is of e.g. type "key" and the first action of the next button is as well, then the "key" prefix will be missing from the printed output of that second button's actions. Making this variable non-static fixes this issue and ensures each run of the function is independent. Fixes: http://sourceforge.net/p/linuxwacom/bugs/303/ Fixes: https://github.com/linuxwacom/xf86-input-wacom/issues/3 Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/xsetwacom.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index c1fec71..95f7a6c 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1951,6 +1951,7 @@ static int get_actions(Display *dpy, XDevice *dev,
unsigned long nitems, bytes_after, *data;
int i;
char buff[1024] = {0};
+ int last_type;
prop = XInternAtom(dpy, param->prop_name, True);
@@ -1979,9 +1980,9 @@ static int get_actions(Display *dpy, XDevice *dev,
AnyPropertyType, &type, &format, &nitems,
&bytes_after, (unsigned char**)&data);
+ last_type = 0;
for (i = 0; i < nitems; i++)
{
- static int last_type;
unsigned long action = data[i];
int current_type;
int detail;