static inline void
tp_begin_touch(struct tp_dispatch *tp, struct tp_touch *t)
{
- struct tp_touch *tmp = NULL;
-
if (t->state != TOUCH_UPDATE) {
tp_motion_history_reset(t);
t->dirty = true;
tp->nfingers_down++;
assert(tp->nfingers_down >= 1);
tp->queued |= TOUCHPAD_EVENT_MOTION;
-
- tp_for_each_touch(tp, tmp) {
- if (tmp->is_pointer)
- break;
- }
-
- if (!tmp->is_pointer) {
- t->is_pointer = true;
- }
}
}
tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t)
{
unsigned int xdist, ydist;
- struct tp_touch *tmp = NULL;
if (!t->pinned.is_pinned)
return;
xdist = abs(t->x - t->pinned.center_x);
ydist = abs(t->y - t->pinned.center_y);
- if (xdist * xdist + ydist * ydist <
- tp->buttons.motion_dist * tp->buttons.motion_dist)
- return;
-
- t->pinned.is_pinned = false;
-
- tp_for_each_touch(tp, tmp) {
- if (tmp->is_pointer)
- break;
+ if (xdist * xdist + ydist * ydist >=
+ tp->buttons.motion_dist * tp->buttons.motion_dist) {
+ t->pinned.is_pinned = false;
+ tp_set_pointer(tp, t);
}
-
- if (t->state != TOUCH_END && !tmp->is_pointer)
- t->is_pointer = true;
}
static void
}
}
+static int
+tp_touch_active(struct tp_dispatch *tp, struct tp_touch *t)
+{
+ return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) &&
+ !t->pinned.is_pinned && tp_button_touch_active(tp, t);
+}
+
+void
+tp_set_pointer(struct tp_dispatch *tp, struct tp_touch *t)
+{
+ struct tp_touch *tmp = NULL;
+
+ /* Only set the touch as pointer if we don't have one yet */
+ tp_for_each_touch(tp, tmp) {
+ if (tmp->is_pointer)
+ return;
+ }
+
+ if (tp_touch_active(tp, t))
+ t->is_pointer = true;
+}
+
static void
tp_process_state(struct tp_dispatch *tp, uint32_t time)
{
void
tp_get_delta(struct tp_touch *t, double *dx, double *dy);
+void
+tp_set_pointer(struct tp_dispatch *tp, struct tp_touch *t);
+
int
tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time);
int
tp_button_handle_state(struct tp_dispatch *tp, uint32_t time);
+int
+tp_button_touch_active(struct tp_dispatch *tp, struct tp_touch *t);
+
#endif
litest_drain_events(li);
- litest_touch_down(dev, 0, 50, 50);
- litest_touch_down(dev, 1, 70, 70);
- litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5);
- litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
+ litest_touch_down(dev, 0, 20, 20);
+ litest_touch_down(dev, 1, 70, 20);
+ litest_touch_move_to(dev, 0, 20, 20, 80, 80, 5);
+ litest_touch_move_to(dev, 1, 70, 20, 80, 50, 5);
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);