diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-12-24 14:22:14 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-12-28 16:10:03 +0000 |
| commit | c9086e6d4f6ef25196843dcc9ee80906dd7d1534 (patch) | |
| tree | c93494dafc136f44798fd668a401ee40728cb0a8 /input.c | |
| parent | term_mouse_grabbed(): make ‘seat’ argument const (diff) | |
input: apply scrollback.multplier in alterate scroll mode
Before this patch, foot only applied [scrollback].multiplier on the
normal screen, never the alt screen.
However, scrolling can be done in two ways on the alt screen:
If the application has enabled mouse support, we simply pass on the
mouse scroll events to the application. Here, it makes sense to not
apply the multiplier, and instead let the application choose how much
to scroll for each scroll event.
But, if the application has not enabled mouse support, we can still
scroll by simulating the arrow keys being pressed - alternate
scrolling (private mode 1007).
This is enabled by default in foot (but can be disabled in foot.ini
with the [mouse].alternate-scroll-mode setting).
In this mode, it makes more sense to apply the multiplier. And that’s
what this patch changes - the multiplier is now applied, on the alt
screen, when the application has not enabled mouse support, and
alternate scrolling has been enabled in foot.
Closes #859
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -2576,9 +2576,10 @@ mouse_scroll(struct seat *seat, int amount, enum wl_pointer_axis axis) } static float -mouse_scroll_multiplier(const struct terminal *term) +mouse_scroll_multiplier(const struct terminal *term, const struct seat *seat) { - return term->grid == &term->normal + return (term->grid == &term->normal || + (term_mouse_grabbed(term, seat) && term->alt_scrolling)) ? term->conf->scrollback.multiplier : 1.0; } @@ -2595,6 +2596,8 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, xassert(seat->mouse_focus != NULL); xassert(axis < ALEN(seat->mouse.aggregated)); + const struct terminal *term = seat->mouse_focus; + /* * Aggregate scrolled amount until we get at least 1.0 * @@ -2602,7 +2605,7 @@ wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, * anything. */ seat->mouse.aggregated[axis] += - mouse_scroll_multiplier(seat->mouse_focus) * wl_fixed_to_double(value); + mouse_scroll_multiplier(term, seat) * wl_fixed_to_double(value); if (fabs(seat->mouse.aggregated[axis]) < seat->mouse_focus->cell_height) return; @@ -2623,7 +2626,7 @@ wl_pointer_axis_discrete(void *data, struct wl_pointer *wl_pointer, if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { /* Treat mouse wheel left/right as regular buttons */ } else - amount *= mouse_scroll_multiplier(seat->mouse_focus); + amount *= mouse_scroll_multiplier(seat->mouse_focus, seat); mouse_scroll(seat, amount, axis); } |
