[PATCH xf86-input-synaptics 6/8] Ignore motion the first X ms after a clickpad click

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 24 21:42:57 PST 2014


On Fri, Feb 21, 2014 at 10:31:42AM +0100, Hans de Goede wrote:
> 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.

do we really need a property and an option for this? I'm tempted to try for
a hardcoded value here and skip the configurable option until we either find
a value that works well enough for everyone [1] or really have to expose yet
another option.

Cheers,
   Peter

[1] lol

> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  include/synaptics-properties.h |  2 ++
>  man/synaptics.man              | 10 ++++++++++
>  src/properties.c               | 10 ++++++++++
>  src/synaptics.c                | 12 ++++++++++++
>  src/synapticsstr.h             |  2 ++
>  tools/synclient.c              |  1 +
>  6 files changed, 37 insertions(+)
> 
> diff --git a/include/synaptics-properties.h b/include/synaptics-properties.h
> index 19bd2b2..20026fc 100644
> --- a/include/synaptics-properties.h
> +++ b/include/synaptics-properties.h
> @@ -51,6 +51,8 @@
>  /* 8 bit (BOOL) */
>  #define SYNAPTICS_PROP_CLICKPAD "Synaptics ClickPad"
>  
> +#define SYNAPTICS_PROP_CLICKPAD_IGNORE_MOTION_TIME "Synaptics ClickPad Ignore Motion Time"
> +
>  /* 8 bit (BOOL) */
>  #define SYNAPTICS_PROP_TAP_FAST "Synaptics Tap FastTap"
>  
> diff --git a/man/synaptics.man b/man/synaptics.man
> index f2d178f..04d1ca0 100644
> --- a/man/synaptics.man
> +++ b/man/synaptics.man
> @@ -133,6 +133,11 @@ Whether the device is a click pad. See
>  .B ClickPad support
>  for more details. Property: "Synaptics ClickPad"
>  .TP 7
> +.BI "Option \*qClickPadIgnoreMotionTime\*q \*q" integer \*q
> +Time (in milliseconds) to ignore motion after a clickpad click. See
> +.B ClickPad support
> +for more details. Property: "Synaptics ClickPad Ignore Motion Time"
> +.TP 7
>  .BI "Option \*qVertEdgeScroll\*q \*q" boolean \*q
>  Enable vertical scrolling when dragging along the right edge. Property:
>  "Synaptics Edge Scrolling"
> @@ -717,6 +722,11 @@ ClickPads provide software emulated buttons through
>  These buttons enable areas on the touchpad to perform as right or middle
>  mouse button. When the user performs a click within a defined soft button
>  area, a right or middle click is performed.
> +.LP
> +Since pressing the pad to click often generates unwanted motion events,
> +motion is ignored for
> +.B Option ClickPadIgnoreMotionTime
> +milliseconds after a click.
>  
>  .SH "DEVICE PROPERTIES"
>  Synaptics 1.0 and higher support input device properties if the driver is
> diff --git a/src/properties.c b/src/properties.c
> index d4fd3cb..b7bee89 100644
> --- a/src/properties.c
> +++ b/src/properties.c
> @@ -58,6 +58,7 @@ Atom prop_tap_time = 0;
>  Atom prop_tap_move = 0;
>  Atom prop_tap_durations = 0;
>  Atom prop_clickpad = 0;
> +Atom prop_clickpad_ignore_motion_time = 0;
>  Atom prop_middle_timeout = 0;
>  Atom prop_twofinger_pressure = 0;
>  Atom prop_twofinger_width = 0;
> @@ -219,6 +220,9 @@ InitDeviceProperties(InputInfoPtr pInfo)
>          InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_DURATIONS, 32, 3, values);
>      prop_clickpad =
>          InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICKPAD, 8, 1, &para->clickpad);
> +    prop_clickpad_ignore_motion_time =
> +        InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICKPAD_IGNORE_MOTION_TIME, 32, 1,
> +                 &para->clickpad_ignore_motion_time);
>      prop_middle_timeout =
>          InitAtom(pInfo->dev, SYNAPTICS_PROP_MIDDLE_TIMEOUT, 32, 1,
>                   &para->emulate_mid_button_time);
> @@ -468,6 +472,12 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
>  
>          para->clickpad = *(BOOL *) prop->data;
>      }
> +    else if (property == prop_clickpad_ignore_motion_time) {
> +        if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
> +            return BadMatch;
> +
> +        para->clickpad_ignore_motion_time = *(INT32 *) prop->data;
> +    }
>      else if (property == prop_middle_timeout) {
>          if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
>              return BadMatch;
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 84e704b..bd14100 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -683,6 +683,7 @@ set_default_parameters(InputInfoPtr pInfo)
>      pars->tap_time_2 = xf86SetIntOption(opts, "MaxDoubleTapTime", 180);
>      pars->click_time = xf86SetIntOption(opts, "ClickTime", 100);
>      pars->clickpad = xf86SetBoolOption(opts, "ClickPad", pars->clickpad);       /* Probed */
> +    pars->clickpad_ignore_motion_time = xf86SetIntOption(opts, "ClickPadIgnoreMotionTime", 100);
>      /* middle mouse button emulation on a clickpad? nah, you're joking */
>      middle_button_timeout = pars->clickpad ? 0 : 75;
>      pars->emulate_mid_button_time =
> @@ -1043,6 +1044,7 @@ SynapticsReset(SynapticsPrivate * priv)
>      priv->count_packet_finger = 0;
>      priv->finger_state = FS_UNTOUCHED;
>      priv->last_motion_millis = 0;
> +    priv->clickpad_click_millis = 0;
>      priv->inside_button_area = FALSE;
>      priv->tap_state = TS_START;
>      priv->tap_button = 0;
> @@ -2824,6 +2826,7 @@ update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw,
>                  hw->left = 0;
>                  hw->middle = 1;
>              }
> +            priv->clickpad_click_millis = now;
>          }
>          else if (hw->left) {
>              hw->left   = (priv->lastButtons & 1) ? 1 : 0;
> @@ -3148,6 +3151,15 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
>      if (priv->has_scrollbuttons)
>          double_click = adjust_state_from_scrollbuttons(pInfo, hw);
>  
> +    /* Ignore motion the first X ms after a clickpad click */
> +    if (priv->clickpad_click_millis) {
> +        if(TIME_DIFF(priv->clickpad_click_millis +
> +                     para->clickpad_ignore_motion_time, now) > 0)
> +            ignore_motion = TRUE;
> +        else
> +            priv->clickpad_click_millis = 0;
> +    }
> +
>      /* now we know that these _coordinates_ aren't in the area.
>         invalid are: x, y, z, numFingers, fingerWidth
>         valid are: millis, left/right/middle/up/down/etc.
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 6d8b0c0..f311ad3 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -160,6 +160,7 @@ typedef struct _SynapticsParameters {
>      int tap_time_2;             /* max. tapping time for double taps */
>      int click_time;             /* The duration of a single click */
>      Bool clickpad;              /* Device is a has integrated buttons */
> +    int clickpad_ignore_motion_time; /* Ignore motion for X ms after a click */
>      int emulate_mid_button_time;        /* Max time between left and right button presses to
>                                             emulate a middle button press. */
>      int emulate_twofinger_z;    /* pressure threshold to emulate two finger touch (for Alps) */
> @@ -250,6 +251,7 @@ struct _SynapticsPrivateRec {
>      enum FingerState finger_state;      /* previous finger state */
>      CARD32 last_motion_millis;  /* time of the last motion */
>      Bool inside_button_area;    /* Inside button area (ignore motion) */
> +    int clickpad_click_millis;  /* Time of last clickpad click */
>  
>      enum TapState tap_state;    /* State of tap processing */
>      int tap_max_fingers;        /* Max number of fingers seen since entering start state */
> diff --git a/tools/synclient.c b/tools/synclient.c
> index 98285ac..ac75e6e 100644
> --- a/tools/synclient.c
> +++ b/tools/synclient.c
> @@ -140,6 +140,7 @@ static struct Parameter params[] = {
>      {"HorizHysteresis",       PT_INT,    0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32,	0},
>      {"VertHysteresis",        PT_INT,    0, 10000, SYNAPTICS_PROP_NOISE_CANCELLATION, 32,	1},
>      {"ClickPad",              PT_BOOL,   0, 1,     SYNAPTICS_PROP_CLICKPAD,	8,	0},
> +    {"ClickPadIgnoreMotionTime", PT_INT, 0, 1000,  SYNAPTICS_PROP_CLICKPAD_IGNORE_MOTION_TIME,  32,	0},
>      {"RightButtonAreaLeft",   PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS,	32,	0},
>      {"RightButtonAreaRight",  PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS,	32,	1},
>      {"RightButtonAreaTop",    PT_INT, INT_MIN, INT_MAX, SYNAPTICS_PROP_SOFTBUTTON_AREAS,	32,	2},
> -- 
> 1.9.0
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list