This patch changes the how pointer access is arbitrated. Before,
any non-touch tool would be immediately granted control over the
pointer, preempting touch itself. This is problematic if the user
happens to use a device with a puck (i.e., a Cursor device) since
the tool is likely to be in-range but idle for a significant
ammount of time.

This patch adds conditions which allow touch to grab control from
the puck if no events have been seen from it in a while. In addition,
the puck may not immediatley regain control from the touch device
while it is in use due to potential hardware jitter.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 src/wcmCommon.c     | 15 ++++++++++++++-
 src/wcmISDV4.c      |  3 +++
 src/wcmUSB.c        |  6 ++++++
 src/xf86WacomDefs.h |  1 +
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 1be6977..7ffab2a 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -859,8 +859,21 @@ static Bool check_arbitrated_control(InputInfoPtr pInfo, 
WacomDeviceStatePtr ds)
                /* Pad may never be the "active" pointer controller */
                return FALSE;
        }
+       else if (IsCursor(active) && IsTouch(priv)) {
+               /* Cursor devices are often left idle in range, so allow touch 
to
+                * grab control if the tool has not been used for some time.
+                */
+               return (ds->time - active->oldState.time > 100);
+       }
+       else if (IsTouch(active) && IsCursor(priv)) {
+               /* An otherwise idle cursor may still occasionally jitter and 
send
+                * events while the user is making active touches. Do not allow
+                * the cursor to grab control in this particular case.
+                */
+               return FALSE;
+       }
        else {
-               /* Pen and cursor events may take control from touch at any 
time */
+               /* Non-touch input has priority over touch in general */
                return !IsTouch(priv);
        }
 }
diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c
index 1e1ffc1..55439eb 100644
--- a/src/wcmISDV4.c
+++ b/src/wcmISDV4.c
@@ -626,6 +626,7 @@ static int isdv4ParseTouchPacket(InputInfoPtr pInfo, const 
unsigned char *data,
        ds->device_type = TOUCH_ID;
        ds->device_id = TOUCH_DEVICE_ID;
        ds->serial_num = 1;
+       ds->time = (int)GetTimeInMillis();
 
        if (common->wcmPktLength == ISDV4_PKGLEN_TOUCH2FG)
        {
@@ -651,6 +652,7 @@ static int isdv4ParseTouchPacket(InputInfoPtr pInfo, const 
unsigned char *data,
                        ds->device_id = TOUCH_DEVICE_ID;
                        ds->serial_num = 2;
                        ds->proximity = touchdata.finger2.status;
+                       ds->time = (int)GetTimeInMillis();
                        /* time stamp for 2FGT gesture events */
                        if ((ds->proximity && !lastTemp->proximity) ||
                            (!ds->proximity && lastTemp->proximity))
@@ -693,6 +695,7 @@ static int isdv4ParsePenPacket(InputInfoPtr pInfo, const 
unsigned char *data,
                return -1;
        }
 
+       ds->time = (int)GetTimeInMillis();
        ds->proximity = coord.proximity;
 
        /* x and y in "normal" orientetion (wide length is X) */
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 258f0a3..5332702 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -1201,6 +1201,7 @@ static void usbParseAbsEvent(WacomCommonPtr common,
                        change = 0;
        }
 
+       ds->time = (int)GetTimeInMillis();
        channel->dirty |= change;
 }
 
@@ -1279,6 +1280,7 @@ static void usbParseAbsMTEvent(WacomCommonPtr common, 
struct input_event *event)
                        change = 0;
        }
 
+       ds->time = (int)GetTimeInMillis();
        (&common->wcmChannel[private->wcmMTChannel])->dirty |= change;
 }
 
@@ -1391,6 +1393,7 @@ static void usbParseKeyEvent(WacomCommonPtr common,
                        change = 0;
        }
 
+       ds->time = (int)GetTimeInMillis();
        channel->dirty |= change;
 
        if (change)
@@ -1417,6 +1420,7 @@ static void usbParseKeyEvent(WacomCommonPtr common,
                        change = 0;
        }
 
+       ds->time = (int)GetTimeInMillis();
        channel->dirty |= change;
 }
 
@@ -1467,6 +1471,7 @@ static void usbParseBTNEvent(WacomCommonPtr common,
                                change = 0;
        }
 
+       ds->time = (int)GetTimeInMillis();
        channel->dirty |= change;
 }
 
@@ -1749,6 +1754,7 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
                        if (event->code == REL_WHEEL)
                        {
                                ds->relwheel = -event->value;
+                               ds->time = (int)GetTimeInMillis();
                                common->wcmChannel[channel].dirty |= TRUE;
                        }
                        else
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index af1df4e..6db5a51 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -231,6 +231,7 @@ struct _WacomDeviceState
        int throttle;
        int proximity;
        int sample;     /* wraps every 24 days */
+       int time;
 };
 
 static const struct _WacomDeviceState OUTPROX_STATE = {
-- 
2.1.0


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to