[PATCH libinput 04/11] touchpad: Change how we deal with scroll methods
Hans de Goede
hdegoede at redhat.com
Thu Feb 19 23:19:41 PST 2015
Hi,
On 19-02-15 10:50, Peter Hutterer wrote:
> On Wed, Feb 18, 2015 at 01:26:47PM +0100, Hans de Goede wrote:
>> With the upcoming gesture support 2fg scrolling will be handled as part of
>> the main gesture state machine, where as edge scrolling has its own state
>
> typo: whereas
Fixed in my personal tree.
Regards,
Hans
>
> Cheers,
> Peter
>
>> machine, our current way of dispatching scroll "actions" does not play well
>> with this.
>>
>> Change the scroll method handling to treat edge and 2fg scrolling as 2
>> separate state machines. The double scroll calls this introduces will mostly
>> be removed when the gesture handling code lands.
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>> src/evdev-mt-touchpad-edge-scroll.c | 3 ++
>> src/evdev-mt-touchpad.c | 73 +++++++------------------------------
>> 2 files changed, 17 insertions(+), 59 deletions(-)
>>
>> diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
>> index 8d0a13e..df181d5 100644
>> --- a/src/evdev-mt-touchpad-edge-scroll.c
>> +++ b/src/evdev-mt-touchpad-edge-scroll.c
>> @@ -317,6 +317,9 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
>> enum libinput_pointer_axis axis;
>> double dx, dy, *delta;
>>
>> + if (tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE)
>> + return 0;
>> +
>> tp_for_each_touch(tp, t) {
>> if (!t->dirty)
>> continue;
>> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
>> index ae37ab1..a6de661 100644
>> --- a/src/evdev-mt-touchpad.c
>> +++ b/src/evdev-mt-touchpad.c
>> @@ -581,6 +581,9 @@ tp_twofinger_scroll_post_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 2fg scrolling during tap-n-drag */
>> if (tp_tap_dragging(tp))
>> return 0;
>> @@ -606,60 +609,6 @@ tp_twofinger_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
>> }
>>
>> static void
>> -tp_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
>> -{
>> - /* Note this must be always called, so that it knows the state of
>> - * touches when the scroll-mode changes.
>> - */
>> - tp_edge_scroll_handle_state(tp, time);
>> -}
>> -
>> -static int
>> -tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
>> -{
>> - struct libinput *libinput = tp->device->base.seat->libinput;
>> -
>> - switch (tp->scroll.method) {
>> - case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
>> - break;
>> - case LIBINPUT_CONFIG_SCROLL_2FG:
>> - return tp_twofinger_scroll_post_events(tp, time);
>> - case LIBINPUT_CONFIG_SCROLL_EDGE:
>> - return tp_edge_scroll_post_events(tp, time);
>> - case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
>> - log_bug_libinput(libinput, "Unexpected scroll mode\n");
>> - break;
>> - }
>> - return 0;
>> -}
>> -
>> -static void
>> -tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time)
>> -{
>> - struct libinput *libinput = tp->device->base.seat->libinput;
>> -
>> - switch (tp->scroll.method) {
>> - case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
>> - break;
>> - case LIBINPUT_CONFIG_SCROLL_2FG:
>> - tp_twofinger_stop_scroll(tp, time);
>> - break;
>> - case LIBINPUT_CONFIG_SCROLL_EDGE:
>> - tp_edge_scroll_stop_events(tp, time);
>> - break;
>> - case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
>> - log_bug_libinput(libinput, "Unexpected scroll mode\n");
>> - break;
>> - }
>> -}
>> -
>> -static void
>> -tp_remove_scroll(struct tp_dispatch *tp)
>> -{
>> - tp_remove_edge_scroll(tp);
>> -}
>> -
>> -static void
>> tp_unhover_touches(struct tp_dispatch *tp, uint64_t time)
>> {
>> struct tp_touch *t;
>> @@ -749,7 +698,7 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time)
>> }
>>
>> tp_button_handle_state(tp, time);
>> - tp_scroll_handle_state(tp, time);
>> + tp_edge_scroll_handle_state(tp, time);
>>
>> /*
>> * We have a physical button down event on a clickpad. To avoid
>> @@ -862,11 +811,14 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time)
>> filter_motion |= tp_post_button_events(tp, time);
>>
>> if (filter_motion || tp->sendevents.trackpoint_active) {
>> - tp_stop_scroll_events(tp, time);
>> + tp_edge_scroll_stop_events(tp, time);
>> + tp_twofinger_stop_scroll(tp, time);
>> return;
>> }
>>
>> - if (tp_post_scroll_events(tp, time) != 0)
>> + if (tp_edge_scroll_post_events(tp, time) != 0)
>> + return;
>> + if (tp_twofinger_scroll_post_events(tp, time) != 0)
>> return;
>>
>> tp_post_pointer_motion(tp, time);
>> @@ -925,7 +877,7 @@ tp_remove(struct evdev_dispatch *dispatch)
>> tp_remove_tap(tp);
>> tp_remove_buttons(tp);
>> tp_remove_sendevents(tp);
>> - tp_remove_scroll(tp);
>> + tp_remove_edge_scroll(tp);
>> }
>>
>> static void
>> @@ -1255,11 +1207,14 @@ tp_scroll_config_scroll_method_set_method(struct libinput_device *device,
>> {
>> struct evdev_device *evdev = (struct evdev_device*)device;
>> struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch;
>> + uint64_t time = libinput_now(device->seat->libinput);
>>
>> if (method == tp->scroll.method)
>> return LIBINPUT_CONFIG_STATUS_SUCCESS;
>>
>> - tp_stop_scroll_events(tp, libinput_now(device->seat->libinput));
>> + tp_edge_scroll_stop_events(tp, time);
>> + tp_twofinger_stop_scroll(tp, time);
>> +
>> tp->scroll.method = method;
>>
>> return LIBINPUT_CONFIG_STATUS_SUCCESS;
>> --
>> 2.1.0
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>
More information about the wayland-devel
mailing list