mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-10 22:10:15 +01:00
touchpad: Move 2 finger scrolling functions to above tp_process_state()
This is purely a code move, this is a preparation patch for adding edge scrolling support. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
348cff5701
commit
26080263e6
1 changed files with 59 additions and 59 deletions
|
|
@ -398,6 +398,65 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
|
|||
t->palm.y = t->y;
|
||||
}
|
||||
|
||||
static void
|
||||
tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
struct tp_touch *t;
|
||||
int nchanged = 0;
|
||||
double dx = 0, dy =0;
|
||||
double tmpx, tmpy;
|
||||
|
||||
tp_for_each_touch(tp, t) {
|
||||
if (tp_touch_active(tp, t) && t->dirty) {
|
||||
nchanged++;
|
||||
tp_get_delta(t, &tmpx, &tmpy);
|
||||
|
||||
dx += tmpx;
|
||||
dy += tmpy;
|
||||
}
|
||||
/* Stop spurious MOTION events at the end of scrolling */
|
||||
t->is_pointer = false;
|
||||
}
|
||||
|
||||
if (nchanged == 0)
|
||||
return;
|
||||
|
||||
dx /= nchanged;
|
||||
dy /= nchanged;
|
||||
|
||||
tp_filter_motion(tp, &dx, &dy, time);
|
||||
|
||||
evdev_post_scroll(tp->device, time, dx, dy);
|
||||
}
|
||||
|
||||
static int
|
||||
tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
struct tp_touch *t;
|
||||
int nfingers_down = 0;
|
||||
|
||||
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
|
||||
return 0;
|
||||
|
||||
/* No scrolling during tap-n-drag */
|
||||
if (tp_tap_dragging(tp))
|
||||
return 0;
|
||||
|
||||
/* Only count active touches for 2 finger scrolling */
|
||||
tp_for_each_touch(tp, t) {
|
||||
if (tp_touch_active(tp, t))
|
||||
nfingers_down++;
|
||||
}
|
||||
|
||||
if (nfingers_down != 2) {
|
||||
evdev_stop_scroll(tp->device, time);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tp_post_twofinger_scroll(tp, time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
tp_process_state(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
|
|
@ -466,65 +525,6 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
|
|||
tp->queued = TOUCHPAD_EVENT_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
struct tp_touch *t;
|
||||
int nchanged = 0;
|
||||
double dx = 0, dy =0;
|
||||
double tmpx, tmpy;
|
||||
|
||||
tp_for_each_touch(tp, t) {
|
||||
if (tp_touch_active(tp, t) && t->dirty) {
|
||||
nchanged++;
|
||||
tp_get_delta(t, &tmpx, &tmpy);
|
||||
|
||||
dx += tmpx;
|
||||
dy += tmpy;
|
||||
}
|
||||
/* Stop spurious MOTION events at the end of scrolling */
|
||||
t->is_pointer = false;
|
||||
}
|
||||
|
||||
if (nchanged == 0)
|
||||
return;
|
||||
|
||||
dx /= nchanged;
|
||||
dy /= nchanged;
|
||||
|
||||
tp_filter_motion(tp, &dx, &dy, time);
|
||||
|
||||
evdev_post_scroll(tp->device, time, dx, dy);
|
||||
}
|
||||
|
||||
static int
|
||||
tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
struct tp_touch *t;
|
||||
int nfingers_down = 0;
|
||||
|
||||
if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_2FG)
|
||||
return 0;
|
||||
|
||||
/* No scrolling during tap-n-drag */
|
||||
if (tp_tap_dragging(tp))
|
||||
return 0;
|
||||
|
||||
/* Only count active touches for 2 finger scrolling */
|
||||
tp_for_each_touch(tp, t) {
|
||||
if (tp_touch_active(tp, t))
|
||||
nfingers_down++;
|
||||
}
|
||||
|
||||
if (nfingers_down != 2) {
|
||||
evdev_stop_scroll(tp->device, time);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tp_post_twofinger_scroll(tp, time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
tp_post_events(struct tp_dispatch *tp, uint64_t time)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue