diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-04-11 14:19:04 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-04-15 06:10:08 +0200 |
| commit | 4846c7cefc0a03ac69576ccebdb8e16055c57461 (patch) | |
| tree | a870f5c5a9406ddf6b13dcbe77e0ced0f82eff31 | |
| parent | f50f824f0e32aaa60ebf30fe66a002182c26c8a4 (diff) | |
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.c | 36 |
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) | |||
| 180 | xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0); | 180 | xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0); |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static void button_scroll(LocalDevicePtr local, | ||
| 184 | int btdec, int btinc, | ||
| 185 | int *scroll, int step, | ||
| 186 | int delta) | ||
| 187 | { | ||
| 188 | *scroll += delta; | ||
| 189 | while (*scroll > step) { | ||
| 190 | tickle_button(local, btinc); | ||
| 191 | *scroll -= step; | ||
| 192 | } | ||
| 193 | while (*scroll < -step) { | ||
| 194 | tickle_button(local, btdec); | ||
| 195 | *scroll += step; | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 183 | static void handle_gestures(LocalDevicePtr local, | 199 | static void handle_gestures(LocalDevicePtr local, |
| 184 | const struct Gestures *gs, | 200 | const struct Gestures *gs, |
| 185 | const struct Capabilities *caps) | 201 | const struct Capabilities *caps) |
| @@ -201,27 +217,11 @@ static void handle_gestures(LocalDevicePtr local, | |||
| 201 | TRACE2("motion: %d %d\n", gs->dx, gs->dy); | 217 | TRACE2("motion: %d %d\n", gs->dx, gs->dy); |
| 202 | } | 218 | } |
| 203 | if (GETBIT(gs->type, GS_VSCROLL)) { | 219 | if (GETBIT(gs->type, GS_VSCROLL)) { |
| 204 | vscroll += gs->dy; | 220 | button_scroll(local, 4, 5, &vscroll, vstep, gs->dy); |
| 205 | while (vscroll > vstep) { | ||
| 206 | tickle_button(local, 5); | ||
| 207 | vscroll -= vstep; | ||
| 208 | } | ||
| 209 | while (vscroll < -vstep) { | ||
| 210 | tickle_button(local, 4); | ||
| 211 | vscroll += vstep; | ||
| 212 | } | ||
| 213 | TRACE1("vscroll: %d\n", gs->dy); | 221 | TRACE1("vscroll: %d\n", gs->dy); |
| 214 | } | 222 | } |
| 215 | if (GETBIT(gs->type, GS_HSCROLL)) { | 223 | if (GETBIT(gs->type, GS_HSCROLL)) { |
| 216 | hscroll += gs->dx; | 224 | button_scroll(local, 6, 7, &hscroll, hstep, gs->dx); |
| 217 | while (hscroll > hstep) { | ||
| 218 | tickle_button(local, 7); | ||
| 219 | hscroll -= hstep; | ||
| 220 | } | ||
| 221 | while (hscroll < -hstep) { | ||
| 222 | tickle_button(local, 6); | ||
| 223 | hscroll += hstep; | ||
| 224 | } | ||
| 225 | TRACE1("hscroll: %d\n", gs->dx); | 225 | TRACE1("hscroll: %d\n", gs->dx); |
| 226 | } | 226 | } |
| 227 | } | 227 | } |
