diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-04-10 16:43:29 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-04-10 16:43:29 +0000 |
| commit | 00dbe12e4196a781bb320070569274e2f1793a4d (patch) | |
| tree | f09226e19743dbe3b89dc06be8d106dc7429c9d6 | |
| parent | render: don't dim so much when in search mode (diff) | |
input: slow trackpad scrolling now eventually scroll a line
Before, we converted each axis event's scroll amount to an integer and
scrolled that many lines.
However, axis events are speed sensitive - very slow scrolling will
result in events with a scroll amount that is < 1.0.
For us, this meant we never scrolled a single line. You could slow
scroll all day if you wanted, and still we would never scroll a single
line.
Fix this by aggregating the scroll amount from axis events until the
scroll amount is > 1.0, and then scroll.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | input.c | 18 | ||||
| -rw-r--r-- | wayland.h | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 372db0f6..0a336623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ * Hostname in OSC 7 URI not being validated. * OSC 4 with multiple `c;spec` pairs. * Alt+Return to emit "ESC \r". +* Trackpad sloooow scrolling to eventually scroll a line. ### Security @@ -1295,7 +1295,18 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, if (wayl->mouse.have_discrete) return; - mouse_scroll(wayl, wl_fixed_to_int(value)); + /* + * Aggregate scrolled amount until we get at least 1.0 + * + * Without this, very slow scrolling will never actually scroll + * anything. + */ + wayl->mouse.axis_aggregated += wl_fixed_to_double(value); + + if (fabs(wayl->mouse.axis_aggregated) >= 1.) { + mouse_scroll(wayl, round(wayl->mouse.axis_aggregated)); + wayl->mouse.axis_aggregated = 0.; + } } static void @@ -1327,6 +1338,11 @@ static void wl_pointer_axis_stop(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis) { + if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL) + return; + + struct wayland *wayl = data; + wayl->mouse.axis_aggregated = 0.; } const struct wl_pointer_listener pointer_listener = { @@ -292,6 +292,7 @@ struct wayland { struct timeval last_time; /* We used a discrete axis event in the current pointer frame */ + double axis_aggregated; bool have_discrete; } mouse; |
