summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-12-10 11:25:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-12-20 15:01:56 +1000
commit1e205eece628b9551648d915b7c4bba79eb87eda (patch)
tree9e9b02c70d411d3e0791229886a2c7dcda2a13eb
parent0e92df6889b8ec928603a7c11792699afa7347a2 (diff)
downloadxf86-input-wacom-1e205eece628b9551648d915b7c4bba79eb87eda.tar.gz
Change wcmDevSwitchModeCall to take and return a Bool
Let the caller handle the X11 constants and just take an "is_absolute" boolean and return a boolean to indicate success Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/wcmCommon.c21
-rw-r--r--src/x11/xf86Wacom.c9
-rw-r--r--src/xf86Wacom.h2
3 files changed, 15 insertions, 17 deletions
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 85c0b3b..87d8ecf 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -80,25 +80,16 @@ void set_absolute(WacomDevicePtr priv, Bool absolute)
* wcmDevSwitchModeCall --
*****************************************************************************/
-int wcmDevSwitchModeCall(WacomDevicePtr priv, int mode)
+Bool wcmDevSwitchModeCall(WacomDevicePtr priv, Bool absolute)
{
- DBG(3, priv, "to mode=%d\n", mode);
+ DBG(3, priv, "to mode=%s\n", absolute ? "absolute" : "relative");
/* Pad is always in absolute mode.*/
if (IsPad(priv))
- return (mode == Absolute) ? Success : XI_BadMode;
-
- if ((mode == Absolute) && !is_absolute(priv))
- set_absolute(priv, TRUE);
- else if ((mode == Relative) && is_absolute(priv))
- set_absolute(priv, FALSE);
- else if ( (mode != Absolute) && (mode != Relative))
- {
- DBG(10, priv, "invalid mode=%d\n", mode);
- return XI_BadMode;
- }
-
- return Success;
+ return absolute;
+ else
+ set_absolute(priv, absolute);
+ return TRUE;
}
diff --git a/src/x11/xf86Wacom.c b/src/x11/xf86Wacom.c
index d28541b..af8e5b9 100644
--- a/src/x11/xf86Wacom.c
+++ b/src/x11/xf86Wacom.c
@@ -838,14 +838,21 @@ out:
static int wcmDevSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode)
{
InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+ Bool is_absolute = TRUE;
#ifdef DEBUG
WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
DBG(3, priv, "dev=%p mode=%d\n",
(void *)dev, mode);
#endif
+ if (mode != Absolute) {
+ if (mode != Relative)
+ return XI_BadMode;
+ is_absolute = FALSE;
+ }
+
/* Share this call with sendAButton in wcmCommon.c */
- return wcmDevSwitchModeCall(priv, mode);
+ return wcmDevSwitchModeCall(priv, is_absolute) ? Success : XI_BadMode;
}
static int preInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
index 8cd121d..6c69a60 100644
--- a/src/xf86Wacom.h
+++ b/src/xf86Wacom.h
@@ -128,7 +128,7 @@ extern Bool wcmPreInitParseOptions(WacomDevicePtr priv, Bool is_primary, Bool is
extern Bool wcmPostInitParseOptions(WacomDevicePtr priv, Bool is_primary, Bool is_dependent);
extern int wcmParseSerials(WacomDevicePtr priv);
-extern int wcmDevSwitchModeCall(WacomDevicePtr priv, int mode);
+extern Bool wcmDevSwitchModeCall(WacomDevicePtr priv, Bool absolute);
extern void wcmResetButtonAction(WacomDevicePtr priv, int button);
extern void wcmResetStripAction(WacomDevicePtr priv, int index);