Moved TPCButton initialization from other routines to wcmParseOptions
of wcmValidateDevice.c. For hotplugged tablets, TPCButton will be
initialized once since wcmParseOptions will only be called once. For
tools defined through xorg.conf, we only allow stylus to define this
option.

Moved wcmTouch inside ISBITSET BTN_TOOL_DOUBLETAP check since only
the devices that support touch would have this option. Same rule
applies to wcmGesture. For hotplugged tablets, these two options
will be initialized once since wcmParseOptions will only be called
once. For tools defined through xorg.conf, only touch can change
these options.

If a tool other than touch tries to set those common touch options,
a warning will be reported and the option will be ignored.

Signed-off-by: Ping Cheng <[email protected]>
---
 src/wcmConfig.c         |    2 +-
 src/wcmISDV4.c          |    7 ------
 src/wcmUSB.c            |    7 ------
 src/wcmValidateDevice.c |   55 +++++++++++++++++++++++++++++++++-------------
 src/xf86Wacom.c         |    3 --
 src/xf86Wacom.h         |    2 +-
 6 files changed, 41 insertions(+), 35 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 34b00c5..29d9f38 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -411,7 +411,7 @@ static LocalDevicePtr wcmPreInit(InputDriverPtr drv, 
IDevPtr dev, int flags)
 
        /* Process the common options. */
        xf86ProcessCommonOptions(local, local->options);
-       if (!wcmParseOptions(local))
+       if (!wcmParseOptions(local, need_hotplug))
                goto SetupProc_fail;
 
        /* mark the device configured */
diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c
index b63bc9f..4b8f803 100644
--- a/src/wcmISDV4.c
+++ b/src/wcmISDV4.c
@@ -172,13 +172,6 @@ static Bool isdv4Init(LocalDevicePtr local, char* id, 
float *version)
        /*set the model */
        common->wcmModel = &isdv4General;
 
-       /* Tablet PC Button is on by default */
-       common->wcmTPCButtonDefault = 1;
-
-       /* check if TPCButton was turned off by user for stylus */
-       if (priv->flags & STYLUS_ID)
-               common->wcmTPCButton = xf86SetBoolOption(local->options,
-                       "TPCButton", common->wcmTPCButtonDefault);
        return Success;
 }
 
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index b83b64e..90df2d8 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -447,13 +447,6 @@ static Bool usbWcmInit(LocalDevicePtr local, char* id, 
float *version)
                                common->wcmResolY = WacomModelDesc [i].yRes;
                        }
                }
-
-               if (common->wcmModel && TabletHasFeature(common, WCM_TPC))
-               {
-                       /* For penabled Tablet PCs, Tablet PC Button
-                        * are on by default */
-                       common->wcmTPCButtonDefault = 1;
-               }
        }
 
        if (!common->wcmModel)
diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index b8b3458..ccc2aac 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -381,7 +381,7 @@ int wcmNeedAutoHotplug(LocalDevicePtr local, const char 
**type)
        return 1;
 }
 
-int wcmParseOptions(LocalDevicePtr local)
+int wcmParseOptions(LocalDevicePtr local, int hotplugged)
 {
        WacomDevicePtr  priv = (WacomDevicePtr)local->private;
        WacomCommonPtr  common = priv->common;
@@ -566,11 +566,18 @@ int wcmParseOptions(LocalDevicePtr local)
        if (xf86SetBoolOption(local->options, "ButtonsOnly", 0))
                priv->flags |= BUTTONS_ONLY_FLAG;
 
-       /* Tablet PC button applied to the whole tablet. Not just one tool */
-       if ( priv->flags & STYLUS_ID )
-               common->wcmTPCButton = xf86SetBoolOption(local->options,
-                                                        "TPCButton",
-                                                        
common->wcmTPCButtonDefault);
+       /* TPCButton on for Tablet PC by default */
+       if (TabletHasFeature(common, WCM_TPC))
+               common->wcmTPCButtonDefault = 1;
+
+       oldButton = xf86SetBoolOption(local->options, "TPCButton",
+                                       common->wcmTPCButtonDefault);
+
+       if (hotplugged || IsStylus(priv))
+               common->wcmTPCButton = oldButton;
+       else if (oldButton != common->wcmTPCButton)
+               xf86Msg(X_WARNING, "%s: TPCButton option can only be set "
+                       "by stylus.\n", local->name);
 
        /* a single touch device */
        if (ISBITSET (common->wcmKeys, BTN_TOOL_DOUBLETAP))
@@ -578,6 +585,24 @@ int wcmParseOptions(LocalDevicePtr local)
                /* TouchDefault was off for all devices
                 * except when touch is supported */
                common->wcmTouchDefault = 1;
+
+               oldButton = xf86SetBoolOption(local->options, "Touch",
+                                       common->wcmTouchDefault);
+
+               if (hotplugged || IsTouch(priv))
+                       common->wcmTouch = oldButton;
+               else if (oldButton != common->wcmTouch)
+                       xf86Msg(X_WARNING, "%s: Touch option can only be set "
+                               "by a touch tool.\n", local->name);
+
+               oldButton = xf86SetBoolOption(local->options, "Capacity",
+                                       common->wcmCapacityDefault);
+
+               if (hotplugged || IsTouch(priv))
+                       common->wcmCapacity = oldButton;
+               else if (oldButton != common->wcmCapacity)
+                       xf86Msg(X_WARNING, "%s: Touch Capacity option can only 
be"
+                               "set by a touch tool.\n", local->name);
        }
 
        /* 2FG touch device */
@@ -586,18 +611,16 @@ int wcmParseOptions(LocalDevicePtr local)
                /* GestureDefault was off for all devices
                 * except when multi-touch is supported */
                common->wcmGestureDefault = 1;
-       }
 
-       /* check if touch was turned off in xorg.conf */
-       common->wcmTouch = xf86SetBoolOption(local->options, "Touch",
-               common->wcmTouchDefault);
+               oldButton = xf86SetBoolOption(local->options, "Gesture",
+                                       common->wcmGestureDefault);
 
-       /* Touch gesture applies to the whole tablet */
-       common->wcmGesture = xf86SetBoolOption(local->options, "Gesture",
-                       common->wcmGestureDefault);
-
-       /* Touch capacity applies to the whole tablet */
-       common->wcmCapacity = xf86SetBoolOption(local->options, "Capacity", 
common->wcmCapacityDefault);
+               if (hotplugged || IsTouch(priv))
+                       common->wcmGesture = oldButton;
+               else if (oldButton != common->wcmGesture)
+                       xf86Msg(X_WARNING, "%s: Touch gesture option can only "
+                               "be set by a touch tool.\n", local->name);
+       }
 
        /* Mouse cursor stays in one monitor in a multimonitor setup */
        if ( !priv->wcmMMonitor )
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 0b39ce0..82d9366 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -953,9 +953,6 @@ static Bool wcmOpen(LocalDevicePtr local)
                /* only ISDV4 are supported on X server 1.7 and later */
                common->wcmForceDevice=DEVICE_ISDV4;
                common->wcmDevCls = &gWacomISDV4Device;
-
-               /* Tablet PC buttons on by default */
-               common->wcmTPCButtonDefault = 1;
        }
        else
        {
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
index b711a7d..17fd793 100644
--- a/src/xf86Wacom.h
+++ b/src/xf86Wacom.h
@@ -150,7 +150,7 @@ extern void wcmHotplugOthers(LocalDevicePtr local);
 extern int wcmAutoProbeDevice(LocalDevicePtr local);
 
 /* setup */
-extern int wcmParseOptions(LocalDevicePtr local);
+extern int wcmParseOptions(LocalDevicePtr local, int hotplugged);
 extern void wcmInitialCoordinates(LocalDevicePtr local, int axes);
 extern void wcmInitialScreens(LocalDevicePtr local);
 extern void wcmInitialScreens(LocalDevicePtr local);
-- 
1.6.6.1


------------------------------------------------------------------------------

_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to