summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2017-05-02 22:54:03 -0300
committerPeter Hutterer <peter.hutterer@who-t.net>2017-05-03 12:38:15 +1000
commit8584c044da57a54a6a1bbd41c35f5778020b6886 (patch)
tree01f610c309cd851e0b1d5e9bfa66962f86a2e037
parentb4f9d7a6b52b948007340b5e6cb2f8a9d68ae038 (diff)
touchpad: make use of use tp_for_each_touch
Instead of reimplementing a for loop every time. Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev-mt-touchpad-gestures.c5
-rw-r--r--src/evdev-mt-touchpad.c12
2 files changed, 5 insertions, 12 deletions
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
index 3de6bcd..a20b26d 100644
--- a/src/evdev-mt-touchpad-gestures.c
+++ b/src/evdev-mt-touchpad-gestures.c
@@ -153,13 +153,12 @@ tp_gesture_get_active_touches(const struct tp_dispatch *tp,
struct tp_touch **touches,
unsigned int count)
{
- unsigned int i, n = 0;
+ unsigned int n = 0;
struct tp_touch *t;
memset(touches, 0, count * sizeof(struct tp_touch *));
- for (i = 0; i < tp->ntouches; i++) {
- t = &tp->touches[i];
+ tp_for_each_touch(tp, t) {
if (tp_touch_active(tp, t)) {
touches[n++] = t;
if (n == count)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 54a3c8e..38c3c92 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -920,8 +920,7 @@ tp_unhover_pressure(struct tp_dispatch *tp, uint64_t time)
* _all_ fingers have enough pressure, even if some of the slotted
* ones don't. Anything else gets insane quickly.
*/
- for (i = 0; i < (int)tp->ntouches; i++) {
- t = tp_get_touch(tp, i);
+ tp_for_each_touch(tp, t) {
if (t->state == TOUCH_HOVERING) {
/* avoid jumps when landing a finger */
tp_motion_history_reset(t);
@@ -975,9 +974,7 @@ tp_unhover_fake_touches(struct tp_dispatch *tp, uint64_t time)
*/
if (tp_fake_finger_is_touching(tp) &&
tp->nfingers_down < nfake_touches) {
- for (i = 0; i < (int)tp->ntouches; i++) {
- t = tp_get_touch(tp, i);
-
+ tp_for_each_touch(tp, t) {
if (t->state == TOUCH_HOVERING) {
tp_begin_touch(tp, t, time);
@@ -1135,7 +1132,6 @@ static void
tp_process_state(struct tp_dispatch *tp, uint64_t time)
{
struct tp_touch *t;
- unsigned int i;
bool restart_filter = false;
bool want_motion_reset;
@@ -1145,9 +1141,7 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time)
want_motion_reset = tp_need_motion_history_reset(tp);
- for (i = 0; i < tp->ntouches; i++) {
- t = tp_get_touch(tp, i);
-
+ tp_for_each_touch(tp, t) {
if (want_motion_reset) {
tp_motion_history_reset(t);
t->quirks.reset_motion_history = true;