On Wed, Jun 15, 2011 at 1:05 AM, Daniel Stone <[email protected]> wrote:
> From: Derek Foreman <[email protected]>
>
> Stopping a little short of having a full scroll history, adding
> last_scroll_millis lets us track when the last scroll event we sent was,
> for more accurate timing of coasting in particular.
>
> Signed-off-by: Derek Foreman <[email protected]>
> Reviewed-by: Daniel Stone <[email protected]>
> Reviewed-by: Peter Hutterer <[email protected]>
> ---
> src/synaptics.c | 14 +++++++++-----
> src/synapticsstr.h | 1 +
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> v2: Include HandleScrolling hunks which inexplicably crept into another patch
> in the series.
>
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 95faa42..c14dbf8 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -1754,7 +1754,7 @@ get_delta_for_trackstick(SynapticsPrivate *priv, const
> struct SynapticsHwState *
> double *dx, double *dy)
> {
> SynapticsParameters *para = &priv->synpara;
> - double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> + double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;
Will this cause giant random jump at the beginning of the first
scroll, since last_scroll_millis is uninitialized, or at every
subsequent 'new' scroll, since last_scroll_millis still holds the time
of some ancient scroll?
Maybe I'm missing something?
>
> *dx = (hw->x - priv->trackstick_neutral_x);
> *dy = (hw->y - priv->trackstick_neutral_y);
> @@ -1809,7 +1809,7 @@ get_delta(SynapticsPrivate *priv, const struct
> SynapticsHwState *hw,
> edge_type edge, double *dx, double *dy)
> {
> SynapticsParameters *para = &priv->synpara;
> - double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> + double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;
> double integral;
> double tmpf;
> int x_edge_speed = 0;
> @@ -2215,7 +2215,7 @@ HandleScrolling(SynapticsPrivate *priv, struct
> SynapticsHwState *hw,
> }
>
> if (priv->autoscroll_yspd) {
> - double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> + double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;
> double ddy = para->coasting_friction * dtime;
> priv->autoscroll_y += priv->autoscroll_yspd * dtime;
> delay = MIN(delay, POLL_MS);
> @@ -2236,7 +2236,7 @@ HandleScrolling(SynapticsPrivate *priv, struct
> SynapticsHwState *hw,
> }
>
> if (priv->autoscroll_xspd) {
> - double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> + double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;
> double ddx = para->coasting_friction * dtime;
> priv->autoscroll_x += priv->autoscroll_xspd * dtime;
> delay = MIN(delay, POLL_MS);
> @@ -2600,8 +2600,12 @@ HandleState(InputInfoPtr pInfo, struct
> SynapticsHwState *hw)
> /* Process scroll events only if coordinates are
> * in the Synaptics Area
> */
> - if (inside_active_area)
> + if (inside_active_area &&
> + (scroll.down != 0 || scroll.up != 0 || scroll.left != 0 ||
> + scroll.right != 0)) {
> post_scroll_events(pInfo, scroll);
> + priv->last_scroll_millis = hw->millis;
> + }
>
> if (double_click) {
> post_button_click(pInfo, 1);
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 6a54455..b65069f 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -220,6 +220,7 @@ typedef struct _SynapticsPrivateRec
> double autoscroll_x; /* Accumulated horizontal coasting
> scroll */
> double autoscroll_y; /* Accumulated vertical coasting
> scroll */
> int scroll_packet_count; /* Scroll duration */
> + unsigned long last_scroll_millis; /* time last scroll event posted */
> double frac_x, frac_y; /* absolute -> relative fraction */
> enum MidButtonEmulation mid_emu_state; /* emulated 3rd button */
> int repeatButtons; /* buttons for repeat */
> --
> 1.7.5.3
>
> _______________________________________________
> [email protected]: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel