aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-04-11 14:19:04 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-04-15 06:10:08 +0200
commit4846c7cefc0a03ac69576ccebdb8e16055c57461 (patch)
treea870f5c5a9406ddf6b13dcbe77e0ced0f82eff31
parentf50f824f0e32aaa60ebf30fe66a002182c26c8a4 (diff)
downloadxorg-input-kobomultitouch-4846c7cefc0a03ac69576ccebdb8e16055c57461.tar.gz
xorg-input-kobomultitouch-4846c7cefc0a03ac69576ccebdb8e16055c57461.tar.bz2
xorg-input-kobomultitouch-4846c7cefc0a03ac69576ccebdb8e16055c57461.zip
Break out scrolling code
Move the duplicated scrolling code to a function. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/multitouch.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/multitouch.c b/src/multitouch.c
index 012476d..ebc0033 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -180,6 +180,22 @@ static void tickle_button(LocalDevicePtr local, int id)
xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0);
}
+static void button_scroll(LocalDevicePtr local,
+ int btdec, int btinc,
+ int *scroll, int step,
+ int delta)
+{
+ *scroll += delta;
+ while (*scroll > step) {
+ tickle_button(local, btinc);
+ *scroll -= step;
+ }
+ while (*scroll < -step) {
+ tickle_button(local, btdec);
+ *scroll += step;
+ }
+}
+
static void handle_gestures(LocalDevicePtr local,
const struct Gestures *gs,
const struct Capabilities *caps)
@@ -201,27 +217,11 @@ static void handle_gestures(LocalDevicePtr local,
TRACE2("motion: %d %d\n", gs->dx, gs->dy);
}
if (GETBIT(gs->type, GS_VSCROLL)) {
- vscroll += gs->dy;
- while (vscroll > vstep) {
- tickle_button(local, 5);
- vscroll -= vstep;
- }
- while (vscroll < -vstep) {
- tickle_button(local, 4);
- vscroll += vstep;
- }
+ button_scroll(local, 4, 5, &vscroll, vstep, gs->dy);
TRACE1("vscroll: %d\n", gs->dy);
}
if (GETBIT(gs->type, GS_HSCROLL)) {
- hscroll += gs->dx;
- while (hscroll > hstep) {
- tickle_button(local, 7);
- hscroll -= hstep;
- }
- while (hscroll < -hstep) {
- tickle_button(local, 6);
- hscroll += hstep;
- }
+ button_scroll(local, 6, 7, &hscroll, hstep, gs->dx);
TRACE1("hscroll: %d\n", gs->dx);
}
}