Thanks so much for the clean ups!  The code flow from new patch does
seem aligned now.

For the whole series of your patches:

Reviewed-by: Chris Bagwell <[email protected]>

Hopefully this will be accepted into the RC1 coming up.  You may want
to send the whole series again to list so they all have a x/5 (or what
ever total we are at now) and so Jason doesn't need to figure out
which of old patches to download along with these.

Chris

On Mon, Jan 2, 2012 at 11:59 AM, Alexey Osipov <[email protected]> wrote:
> First, we define two new GESTURE_ modes:
> - GESTURE_PREDRAG_MODE - when first tap happen and we wait for second touch.
> - GESTURE_DRAG_MODE -  when actual drag happening (left button pressed).
>
> Second, we define tap timeout function wcmSingleFingerTapTimer(), which
> simulate single click if no drag operation started within timeout.
>
> Third, we make an exception for GESTURE_DRAG_MODE in wcmCommon.c, because
> we actually want cursor movements while dragging. This exception is made
> through new function wcmTouchNeedSendEvents().
>
> Now, to do a single tap you just tap (touch and untouch). Actual click
> happens after TapTime period.
> To drag something you make a tap (touch and untouch) and then quickly
> (in TapTime period) touch device again. Then drag.
>
> Signed-off-by: Alexey Osipov <[email protected]>
> ---
>
> Original patch name: 'Left mouse button' dragging support.
>
> Changes to previous version:
> - patch split into two parts: this part add a new feature.
> - wcmGestureMode values (GESTURE_*) moved back to wcmTouchFilter.c.
> - GESTURE_DRAG_MODE exception in wcmCommon.c now works using
>  new function wcmTouchNeedSendEvents().
> - standardise location of finger and gesture checks in wcmGestureFilter().
>
>  src/wcmCommon.c      |    4 +-
>  src/wcmTouchFilter.c |   56 ++++++++++++++++++++++++++++++++++++++++++-------
>  src/wcmTouchFilter.h |    2 +
>  3 files changed, 52 insertions(+), 10 deletions(-)
>
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 055583d..0f041e3 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -812,8 +812,8 @@ void wcmSendEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds)
>        if (type == PAD_ID)
>                wcmSendPadEvents(pInfo, ds, 3, priv->naxes - 3, 
> &valuators[3]); /* pad doesn't post x/y/z */
>        else {
> -               /* don't move the cursor if in gesture mode */
> -               if (!priv->common->wcmGestureMode)
> +               /* don't move the cursor if in gesture mode (except drag 
> mode) */
> +               if ((type != TOUCH_ID) || 
> wcmTouchNeedSendEvents(priv->common))
>                        wcmSendNonPadEvents(pInfo, ds, 0, priv->naxes, 
> valuators);
>        }
>
> diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
> index 58c4bb3..9739139 100644
> --- a/src/wcmTouchFilter.c
> +++ b/src/wcmTouchFilter.c
> @@ -1,5 +1,6 @@
>  /*
>  * Copyright 2009 - 2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2011 by Alexey Osipov. <[email protected]>
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -34,6 +35,8 @@
>  #define GESTURE_SCROLL_MODE           2
>  #define GESTURE_ZOOM_MODE             4
>  #define GESTURE_LAG_MODE              8
> +#define GESTURE_PREDRAG_MODE         16
> +#define GESTURE_DRAG_MODE            32
>
>  #define WCM_SCROLL_UP                 5        /* vertical up */
>  #define WCM_SCROLL_DOWN               4        /* vertical down */
> @@ -140,6 +143,23 @@ static void wcmFingerTapToClick(WacomDevicePtr priv)
>        }
>  }
>
> +static CARD32 wcmSingleFingerTapTimer(OsTimerPtr timer, CARD32 time, pointer 
> arg)
> +{
> +       WacomDevicePtr priv = (WacomDevicePtr)arg;
> +       WacomCommonPtr common = priv->common;
> +
> +       if (common->wcmGestureMode == GESTURE_PREDRAG_MODE)
> +       {
> +               /* left button down */
> +               wcmSendButtonClick(priv, 1, 1);
> +
> +               /* left button up */
> +               wcmSendButtonClick(priv, 1, 0);
> +               common->wcmGestureMode = GESTURE_NONE_MODE;
> +       }
> +
> +       return 0;
> +}
>
>  /* A single finger tap is defined as 1 finger tap that lasts less than
>  * wcmTapTime.  It results in a left button press.
> @@ -178,11 +198,10 @@ static void wcmSingleFingerTap(WacomDevicePtr priv)
>                    common->wcmGestureParameters.wcmTapTime &&
>                    ds[1].sample < dsLast[0].sample)
>                {
> -                       /* left button down */
> -                       wcmSendButtonClick(priv, 1, 1);
> +                       common->wcmGestureMode = GESTURE_PREDRAG_MODE;
>
> -                       /* left button up */
> -                       wcmSendButtonClick(priv, 1, 0);
> +                       /* Delay to detect possible drag operation */
> +                       TimerSet(NULL, 0, 
> common->wcmGestureParameters.wcmTapTime, wcmSingleFingerTapTimer, priv);
>                }
>        }
>  }
> @@ -248,17 +267,19 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel)
>                if (common->wcmGestureMode == GESTURE_NONE_MODE)
>                        common->wcmGestureMode = GESTURE_LAG_MODE;
>        }
> -       /* When only 1 finger is in proximity, it can be in either LAG mode
> -        * or NONE mode.
> +       /* When only 1 finger is in proximity, it can be in either LAG mode,
> +        * NONE mode or DRAG mode.
>         * 1 finger LAG mode is a very short time period mainly to debounce
>         * initial touch.
> -        * NONE mode means cursor is allowed to move around.
> +        * NONE and DRAG mode means cursor is allowed to move around.
> +        * DRAG mode in addition means that left button pressed.
> +        * There is no need to bother about LAG_TIME while in DRAG mode.
>         * TODO: This has to use dsLast[0] because of later logic that
>         * wants mode to be NONE still when 1st entering proximity.
>         * That could use some re-arranging/cleanup.
>         *
>         */
> -       else if (dsLast[0].proximity)
> +       else if (dsLast[0].proximity && common->wcmGestureMode != 
> GESTURE_DRAG_MODE)
>        {
>                CARD32 ms = GetTimeInMillis();
>
> @@ -297,6 +318,16 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel)
>                /* initialize the cursor position */
>                if (common->wcmGestureMode == GESTURE_NONE_MODE && !channel)
>                        goto ret;
> +
> +               /* got second touch in TapTime interval after first one,
> +                * switch to DRAG mode */
> +               if (common->wcmGestureMode == GESTURE_PREDRAG_MODE)
> +               {
> +                       /* left button down */
> +                       wcmSendButtonClick(priv, 1, 1);
> +                       common->wcmGestureMode = GESTURE_DRAG_MODE;
> +                       goto ret;
> +               }
>        }
>
>        if (!ds[0].proximity && !ds[1].proximity)
> @@ -307,6 +338,10 @@ void wcmGestureFilter(WacomDevicePtr priv, int channel)
>                        /* send first finger out prox */
>                        wcmSoftOutEvent(priv->pInfo);
>
> +               /* if were in DRAG mode, send left button up now */
> +               if (common->wcmGestureMode == GESTURE_DRAG_MODE)
> +                       wcmSendButtonClick(priv, 1, 0);
> +
>                /* exit gesture mode when both fingers are out */
>                common->wcmGestureMode = GESTURE_NONE_MODE;
>                common->wcmGestureParameters.wcmScrollDirection = 0;
> @@ -561,4 +596,9 @@ static void wcmFingerZoom(WacomDevicePtr priv)
>        }
>  }
>
> +Bool wcmTouchNeedSendEvents(WacomCommonPtr common)
> +{
> +       return !(common->wcmGestureMode & ~GESTURE_DRAG_MODE);
> +}
> +
>  /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
> diff --git a/src/wcmTouchFilter.h b/src/wcmTouchFilter.h
> index 38c73fb..331abde 100644
> --- a/src/wcmTouchFilter.h
> +++ b/src/wcmTouchFilter.h
> @@ -1,5 +1,6 @@
>  /*
>  * Copyright 2009 - 2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2011 by Alexey Osipov. <[email protected]>
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -24,6 +25,7 @@
>  /****************************************************************************/
>
>  void wcmGestureFilter(WacomDevicePtr priv, int channel);
> +Bool wcmTouchNeedSendEvents(WacomCommonPtr common);
>
>  /****************************************************************************/
>  #endif /* __XF86_WCMTOUCHFILTER_H */
> --
> 1.7.0.4
>
>
>
>

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to