[PATCH xf86-input-synaptics 2/2] Don't report motion inside soft-button areas

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 19 20:32:35 PST 2014


On Wed, Feb 19, 2014 at 06:30:36PM +0100, Hans de Goede wrote:
> Unless the motion has started outside the soft-button area.
> 
> This fixes my #1 anoyance with clickpads, where 2 out of 3 clicks turn into
> a click + drag unless I hold my finger really really still.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/synaptics.c    | 33 ++++++++++++++++++++++++++++++++-
>  src/synapticsstr.h |  1 +
>  2 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 8064844..e06c735 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -1027,6 +1027,7 @@ SynapticsReset(SynapticsPrivate * priv)
>      priv->count_packet_finger = 0;
>      priv->finger_state = FS_UNTOUCHED;
>      priv->last_motion_millis = 0;
> +    priv->ignore_motion = FALSE;
>      priv->tap_state = TS_START;
>      priv->tap_button = 0;
>      priv->tap_button_state = TBS_BUTTON_UP;
> @@ -1487,6 +1488,28 @@ is_inside_topmiddlebutton_area(SynapticsParameters * para, int x, int y)
>      return is_inside_button_area(para, 3, x, y);
>  }
>  
> +static Bool
> +is_inside_anybutton_area(SynapticsParameters * para, int x, int y)
> +{
> +    enum {
> +        TOP = 2,
> +        BOTTOM = 3
> +    };

please move the enum from is_inside_anybutton_area out into a top-level so
we can use the same from here too instead of duplicating it.

> +
> +    /* We don't have a left button area, so we simply check for
> +     * y > bottomrightbuttonarea top or y < toprightbuttonarea bottom,
> +     * assuming that all soft buttons have the same height */
> +
> +    if (para->softbutton_areas[0][TOP] && y > para->softbutton_areas[0][TOP])
> +        return TRUE;
> +
> +    if (para->softbutton_areas[2][BOTTOM] &&
> +                                       y < para->softbutton_areas[2][BOTTOM])
> +        return TRUE;

A zero value means "extend to infinity" unless both are zero. In the above
you'd return TRUE for a value of (bottom_edge + N).
it's actually easier to check for outside than inside here, so just swap '>'
and '<' and return FALSE. And you need to check for either top+bottom being
non-zero.

also, the index is wrong, you'll need to check [0] for both of them if you
want the right button area.

Please also add a simple check for right+middle button horizontal alignment.
If they're not aligned in a sensible way, just return false. We do,
unfortunately, allow random placement of the buttons though I'm not sure
whether that is used.

> +    return FALSE;
> +}
> +
>  static CARD32
>  timerFunc(OsTimerPtr timer, CARD32 now, pointer arg)
>  {
> @@ -3024,6 +3047,14 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
>  
>      inside_active_area = is_inside_active_area(priv, hw->x, hw->y);
>  
> +    /* Ignore motion *starting* inside softbuttonareas */
> +    if (priv->finger_state < FS_TOUCHED)
> +        priv->ignore_motion = is_inside_anybutton_area(para, hw->x, hw->y);
> +    /* If we already have a finger down, clear ignore motion if it goes
> +       outside of the softbuttonareas */
> +    else if (!is_inside_anybutton_area(para, hw->x, hw->y))
> +        priv->ignore_motion = FALSE;

to save us a few superfluous checks, I'd use:
   else if (priv->ignore_motion && !is_inside_anybutton_area...

Cheers,
   Peter

> +
>      /* these two just update hw->left, right, etc. */
>      update_hw_button_state(pInfo, hw, priv->old_hw_state, now, &delay);
>      if (priv->has_scrollbuttons)
> @@ -3095,7 +3126,7 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
>      }
>  
>      /* Post events */
> -    if (finger >= FS_TOUCHED && (dx || dy) &&
> +    if (finger >= FS_TOUCHED && (dx || dy) && !priv->ignore_motion &&
>          (para->touchpad_off != TOUCHPAD_CLICK_ONLY))
>          xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy);
>  
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index dee155f..d2fabdf 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -249,6 +249,7 @@ struct _SynapticsPrivateRec {
>      Bool prev_up;               /* Previous up button value, for double click emulation */
>      enum FingerState finger_state;      /* previous finger state */
>      CARD32 last_motion_millis;  /* time of the last motion */
> +    Bool ignore_motion;         /* ignore motion (inside softbutton area) */
>  
>      enum TapState tap_state;    /* State of tap processing */
>      int tap_max_fingers;        /* Max number of fingers seen since entering start state */
> -- 
> 1.8.5.3
> 


More information about the xorg-devel mailing list