summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2011-06-23 13:58:31 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2011-08-25 09:50:34 +1000
commitfb7c0c5965b6843f38e9c881f4c349006ec0da32 (patch)
tree5772eefc751b8cde87b83a8466f6852b0d7be600
parent81a8ddb4a768bee3a4b304716fa4cfead49a2761 (diff)
Scroll: Move scroll_[xya] into new priv->scroll struct
And rename them to last_x, last_y and last_a respectively, as they're used to store the values as of the last scroll event sent. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/synaptics.c54
-rw-r--r--src/synapticsstr.h8
2 files changed, 32 insertions, 30 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index 9e0470e..3344f56 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1966,7 +1966,7 @@ start_coasting(SynapticsPrivate *priv, struct SynapticsHwState *hw,
double scrolls_per_sec = dy / pkt_time / sdelta;
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
priv->autoscroll_yspd = scrolls_per_sec;
- priv->autoscroll_y = (hw->y - priv->scroll_y) / (double)sdelta;
+ priv->autoscroll_y = (hw->y - priv->scroll.last_y) / (double)sdelta;
}
}
}
@@ -1977,7 +1977,7 @@ start_coasting(SynapticsPrivate *priv, struct SynapticsHwState *hw,
double scrolls_per_sec = dx / pkt_time / sdelta;
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
priv->autoscroll_xspd = scrolls_per_sec;
- priv->autoscroll_x = (hw->x - priv->scroll_x) / (double)sdelta;
+ priv->autoscroll_x = (hw->x - priv->scroll.last_x) / (double)sdelta;
}
}
}
@@ -1989,11 +1989,11 @@ start_coasting(SynapticsPrivate *priv, struct SynapticsHwState *hw,
if (fabs(scrolls_per_sec) >= para->coasting_speed) {
if (vert) {
priv->autoscroll_yspd = scrolls_per_sec;
- priv->autoscroll_y = diffa(priv->scroll_a, angle(priv, hw->x, hw->y)) / sdelta;
+ priv->autoscroll_y = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y)) / sdelta;
}
else if (horiz) {
priv->autoscroll_xspd = scrolls_per_sec;
- priv->autoscroll_x = diffa(priv->scroll_a, angle(priv, hw->x, hw->y)) / sdelta;
+ priv->autoscroll_x = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y)) / sdelta;
}
}
}
@@ -2044,7 +2044,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
(para->circular_trigger == 8 && edge & LEFT_EDGE && edge & TOP_EDGE)) {
priv->circ_scroll_on = TRUE;
priv->circ_scroll_vert = TRUE;
- priv->scroll_a = angle(priv, hw->x, hw->y);
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
DBG(7, "circular scroll detected on edge\n");
}
}
@@ -2056,14 +2056,14 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
(para->scroll_twofinger_vert) && (para->scroll_dist_vert != 0)) {
priv->vert_scroll_twofinger_on = TRUE;
priv->vert_scroll_edge_on = FALSE;
- priv->scroll_y = hw->y;
+ priv->scroll.last_y = hw->y;
DBG(7, "vert two-finger scroll detected\n");
}
if (!priv->horiz_scroll_twofinger_on &&
(para->scroll_twofinger_horiz) && (para->scroll_dist_horiz != 0)) {
priv->horiz_scroll_twofinger_on = TRUE;
priv->horiz_scroll_edge_on = FALSE;
- priv->scroll_x = hw->x;
+ priv->scroll.last_x = hw->x;
DBG(7, "horiz two-finger scroll detected\n");
}
}
@@ -2073,13 +2073,13 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
if ((para->scroll_edge_vert) && (para->scroll_dist_vert != 0) &&
(edge & RIGHT_EDGE)) {
priv->vert_scroll_edge_on = TRUE;
- priv->scroll_y = hw->y;
+ priv->scroll.last_y = hw->y;
DBG(7, "vert edge scroll detected on right edge\n");
}
if ((para->scroll_edge_horiz) && (para->scroll_dist_horiz != 0) &&
(edge & BOTTOM_EDGE)) {
priv->horiz_scroll_edge_on = TRUE;
- priv->scroll_x = hw->x;
+ priv->scroll.last_x = hw->x;
DBG(7, "horiz edge scroll detected on bottom edge\n");
}
}
@@ -2162,7 +2162,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
priv->vert_scroll_edge_on = FALSE;
priv->circ_scroll_on = TRUE;
priv->circ_scroll_vert = TRUE;
- priv->scroll_a = angle(priv, hw->x, hw->y);
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
DBG(7, "switching to circular scrolling\n");
}
}
@@ -2181,7 +2181,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
priv->horiz_scroll_edge_on = FALSE;
priv->circ_scroll_on = TRUE;
priv->circ_scroll_vert = FALSE;
- priv->scroll_a = angle(priv, hw->x, hw->y);
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
DBG(7, "switching to circular scrolling\n");
}
}
@@ -2196,13 +2196,13 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
/* + = down, - = up */
int delta = para->scroll_dist_vert;
if (delta > 0) {
- while (hw->y - priv->scroll_y > delta) {
+ while (hw->y - priv->scroll.last_y > delta) {
sd->down++;
- priv->scroll_y += delta;
+ priv->scroll.last_y += delta;
}
- while (hw->y - priv->scroll_y < -delta) {
+ while (hw->y - priv->scroll.last_y < -delta) {
sd->up++;
- priv->scroll_y -= delta;
+ priv->scroll.last_y -= delta;
}
}
}
@@ -2210,13 +2210,13 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
/* + = right, - = left */
int delta = para->scroll_dist_horiz;
if (delta > 0) {
- while (hw->x - priv->scroll_x > delta) {
+ while (hw->x - priv->scroll.last_x > delta) {
sd->right++;
- priv->scroll_x += delta;
+ priv->scroll.last_x += delta;
}
- while (hw->x - priv->scroll_x < -delta) {
+ while (hw->x - priv->scroll.last_x < -delta) {
sd->left++;
- priv->scroll_x -= delta;
+ priv->scroll.last_x -= delta;
}
}
}
@@ -2224,23 +2224,23 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
/* + = counter clockwise, - = clockwise */
double delta = para->scroll_dist_circ;
if (delta >= 0.005) {
- while (diffa(priv->scroll_a, angle(priv, hw->x, hw->y)) > delta) {
+ while (diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y)) > delta) {
if (priv->circ_scroll_vert)
sd->up++;
else
sd->right++;
- priv->scroll_a += delta;
- if (priv->scroll_a > M_PI)
- priv->scroll_a -= 2 * M_PI;
+ priv->scroll.last_a += delta;
+ if (priv->scroll.last_a > M_PI)
+ priv->scroll.last_a -= 2 * M_PI;
}
- while (diffa(priv->scroll_a, angle(priv, hw->x, hw->y)) < -delta) {
+ while (diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y)) < -delta) {
if (priv->circ_scroll_vert)
sd->down++;
else
sd->left++;
- priv->scroll_a -= delta;
- if (priv->scroll_a < -M_PI)
- priv->scroll_a += 2 * M_PI;
+ priv->scroll.last_a -= delta;
+ if (priv->scroll.last_a < -M_PI)
+ priv->scroll.last_a += 2 * M_PI;
}
}
}
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index c50f66c..5c878ef 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -193,9 +193,11 @@ typedef struct _SynapticsPrivateRec
int hist_index; /* Last added entry in move_hist[] */
int hyst_center_x; /* center x of hysteresis*/
int hyst_center_y; /* center y of hysteresis*/
- int scroll_y; /* last y-scroll position */
- int scroll_x; /* last x-scroll position */
- double scroll_a; /* last angle-scroll position */
+ struct {
+ int last_x; /* last x-scroll position */
+ int last_y; /* last y-scroll position */
+ double last_a; /* last angle-scroll position */
+ } scroll;
int count_packet_finger; /* packet counter with finger on the touchpad */
int button_delay_millis; /* button delay for 3rd button emulation */
Bool prev_up; /* Previous up button value, for double click emulation */