[PATCH 05/15] Add last_scroll_millis to track scroll event timing
Daniel Stone
daniel at fooishbar.org
Thu Jun 9 12:57:26 PDT 2011
From: Derek Foreman <derek.foreman at collabora.co.uk>
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 <derek.foreman at collabora.co.uk>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
---
src/synaptics.c | 10 +++++++---
src/synapticsstr.h | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/synaptics.c b/src/synaptics.c
index 8a7c6d1..a4e6a47 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1730,7 +1730,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;
*dx = (hw->x - priv->trackstick_neutral_x);
*dy = (hw->y - priv->trackstick_neutral_y);
@@ -1785,7 +1785,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;
@@ -2575,8 +2575,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 c69ba09..d222cde 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
More information about the xorg-devel
mailing list