Re: [PATCH 2/3] evdev: Move generic scroll code from evdev-mt-touchpad.c to evdev.c
Hi, On 09/03/2014 05:50 AM, Peter Hutterer wrote: On Tue, Sep 02, 2014 at 04:34:49PM +0200, Hans de Goede wrote: So that it can be used for middle button trackpoint scrolling too. Signed-off-by: Hans de Goede hdego...@redhat.com --- src/evdev-mt-touchpad.c | 56 +++-- src/evdev-mt-touchpad.h | 4 src/evdev.c | 48 ++ src/evdev.h | 14 + 4 files changed, 65 insertions(+), 57 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d831b83..059926f 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -492,47 +492,8 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time) dy /= nchanged; tp_filter_motion(tp, dx, dy, time); - /* Require at least five px scrolling to start */ -if (dy = -5.0 || dy = 5.0) -tp-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); - -if (dx = -5.0 || dx = 5.0) -tp-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); - -if (dy != 0.0 -(tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) { -pointer_notify_axis(tp-device-base, -time, -LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -dy); -} - -if (dx != 0.0 -(tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))) { -pointer_notify_axis(tp-device-base, -time, -LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -dx); -} -} - -static void -tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time) -{ -/* terminate scrolling with a zero scroll event */ -if (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) -pointer_notify_axis(tp-device-base, -time, -LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -0); -if (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) -pointer_notify_axis(tp-device-base, -time, -LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -0); - -tp-scroll.direction = 0; +evdev_post_scroll(tp-device, time, dx, dy, 5.0); } static int @@ -548,7 +509,7 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time) } if (nfingers_down != 2) { -tp_stop_scroll_events(tp, time); +evdev_stop_scroll(tp-device, time); return 0; } @@ -567,7 +528,7 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time) consumed |= tp_post_button_events(tp, time); if (consumed) { -tp_stop_scroll_events(tp, time); +evdev_stop_scroll(tp-device, time); return; } @@ -747,14 +708,6 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal) } static int -tp_init_scroll(struct tp_dispatch *tp) -{ -tp-scroll.direction = 0; - -return 0; -} - -static int tp_init_palmdetect(struct tp_dispatch *tp, struct evdev_device *device) { @@ -809,9 +762,6 @@ tp_init(struct tp_dispatch *tp, tp-hysteresis.margin_y = diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR; -if (tp_init_scroll(tp) != 0) -return -1; - if (tp_init_accel(tp, diagonal) != 0) return -1; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 83edf4f..be93c49 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -200,10 +200,6 @@ struct tp_dispatch { } top_area; } buttons; /* physical buttons */ -struct { -enum libinput_pointer_axis direction; -} scroll; - enum touchpad_event queued; struct { diff --git a/src/evdev.c b/src/evdev.c index e24e268..b45f7ec 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1131,6 +1131,54 @@ evdev_device_get_size(struct evdev_device *device, return 0; } +void +evdev_post_scroll(struct evdev_device *device, + uint64_t time, + double dx, + double dy, + double thresh) +{ +if (dy = -thresh || dy = thresh) +device-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + +if (dx = -thresh || dx = thresh) +device-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + +if (dy != 0.0 +(device-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) { +pointer_notify_axis(device-base, +time, +
Re: [PATCH 2/3] evdev: Move generic scroll code from evdev-mt-touchpad.c to evdev.c
On Tue, Sep 02, 2014 at 04:34:49PM +0200, Hans de Goede wrote: So that it can be used for middle button trackpoint scrolling too. Signed-off-by: Hans de Goede hdego...@redhat.com --- src/evdev-mt-touchpad.c | 56 +++-- src/evdev-mt-touchpad.h | 4 src/evdev.c | 48 ++ src/evdev.h | 14 + 4 files changed, 65 insertions(+), 57 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d831b83..059926f 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -492,47 +492,8 @@ tp_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time) dy /= nchanged; tp_filter_motion(tp, dx, dy, time); - /* Require at least five px scrolling to start */ - if (dy = -5.0 || dy = 5.0) - tp-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); - - if (dx = -5.0 || dx = 5.0) - tp-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); - - if (dy != 0.0 - (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) { - pointer_notify_axis(tp-device-base, - time, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, - dy); - } - - if (dx != 0.0 - (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))) { - pointer_notify_axis(tp-device-base, - time, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, - dx); - } -} - -static void -tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time) -{ - /* terminate scrolling with a zero scroll event */ - if (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) - pointer_notify_axis(tp-device-base, - time, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, - 0); - if (tp-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) - pointer_notify_axis(tp-device-base, - time, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, - 0); - - tp-scroll.direction = 0; + evdev_post_scroll(tp-device, time, dx, dy, 5.0); } static int @@ -548,7 +509,7 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time) } if (nfingers_down != 2) { - tp_stop_scroll_events(tp, time); + evdev_stop_scroll(tp-device, time); return 0; } @@ -567,7 +528,7 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time) consumed |= tp_post_button_events(tp, time); if (consumed) { - tp_stop_scroll_events(tp, time); + evdev_stop_scroll(tp-device, time); return; } @@ -747,14 +708,6 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal) } static int -tp_init_scroll(struct tp_dispatch *tp) -{ - tp-scroll.direction = 0; - - return 0; -} - -static int tp_init_palmdetect(struct tp_dispatch *tp, struct evdev_device *device) { @@ -809,9 +762,6 @@ tp_init(struct tp_dispatch *tp, tp-hysteresis.margin_y = diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR; - if (tp_init_scroll(tp) != 0) - return -1; - if (tp_init_accel(tp, diagonal) != 0) return -1; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 83edf4f..be93c49 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -200,10 +200,6 @@ struct tp_dispatch { } top_area; } buttons; /* physical buttons */ - struct { - enum libinput_pointer_axis direction; - } scroll; - enum touchpad_event queued; struct { diff --git a/src/evdev.c b/src/evdev.c index e24e268..b45f7ec 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1131,6 +1131,54 @@ evdev_device_get_size(struct evdev_device *device, return 0; } +void +evdev_post_scroll(struct evdev_device *device, + uint64_t time, + double dx, + double dy, + double thresh) +{ + if (dy = -thresh || dy = thresh) + device-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + + if (dx = -thresh || dx = thresh) + device-scroll.direction |= (1 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + + if (dy != 0.0 + (device-scroll.direction (1 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) { + pointer_notify_axis(device-base, +