mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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.
This commit is contained in:
parent
661fa98cb2
commit
8e04b08615
2 changed files with 12 additions and 4 deletions
|
|
@ -29,6 +29,10 @@
|
|||
(https://codeberg.org/dnkl/foot/issues/141).
|
||||
* Scrollback position is now retained when resizing the window
|
||||
(https://codeberg.org/dnkl/foot/issues/142).
|
||||
* Trackpad scrolling speed. Note that it is much slower compared to
|
||||
previous foot versions. Use the **multiplier** option in `foot.ini`
|
||||
if you find the new speed too slow
|
||||
(https://codeberg.org/dnkl/foot/issues/144).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
12
input.c
12
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue