aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-09-27 09:11:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-10-11 17:23:25 +0000
commit8e04b086158730b615803c45368f1fe7a6bce95e (patch)
tree825fdc61b4c89b1fd71b377ef0fd462f1262d176 /input.c
parentgrid: reflow: fix release build; ‘idx’ is only used in an assert() (diff)
input: trackpad scroll: correctly convert pixel movements to line movements
Trackpad scroll movements are in pixels. Foot previously “translated” these directly to line movements (i.e. a one pixel scroll event was translated into a one line scroll). Now we use the line height of the terminal and correctly convert pixels to lines. This makes the trackpad scroll speed in foot consistent with the scroll speed in e.g. Alacritty and Kitty.
Diffstat (limited to 'input.c')
-rw-r--r--input.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/input.c b/input.c
index cc14d41b..20c1381c 100644
--- a/input.c
+++ b/input.c
@@ -1688,6 +1688,8 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
if (seat->mouse.have_discrete)
return;
+ assert(seat->mouse_focus != NULL);
+
/*
* Aggregate scrolled amount until we get at least 1.0
*
@@ -1697,10 +1699,12 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
seat->mouse.axis_aggregated
+= seat->wayl->conf->scrollback.multiplier * wl_fixed_to_double(value);
- if (fabs(seat->mouse.axis_aggregated) >= 1.) {
- mouse_scroll(seat, round(seat->mouse.axis_aggregated));
- seat->mouse.axis_aggregated = 0.;
- }
+ if (fabs(seat->mouse.axis_aggregated) < seat->mouse_focus->cell_height)
+ return;
+
+ int lines = seat->mouse.axis_aggregated / seat->mouse_focus->cell_height;
+ mouse_scroll(seat, lines);
+ seat->mouse.axis_aggregated -= (double)lines * seat->mouse_focus->cell_height;
}
static void