linux: scrolling improvements (#9103)

This PR adjusts scrolling to be a lot faster on Linux and also makes
terminal scrolling work.

For Wayland, it makes scrolling faster by handling the `AxisValue120`
event (which also allows high-resolution scrolling on supported mice)
On X11, changed the 1 line per scroll to 3.

### Different solutions

I tried replicating Chromium's scrolling behaviour, but it was
inconsistent in X11/Wayland and found it too fast on Wayland. Plus, it
also didn't match VSCode, since it seems that they do something
different.

Release Notes:

- Made scrolling faster on Linux
- Made terminal scroll on Linux
This commit is contained in:
apricotbucket28
2024-03-18 14:50:29 -07:00
committed by GitHub
parent c0f8581b29
commit d8e32c3e3c
4 changed files with 68 additions and 10 deletions
+5 -4
View File
@@ -23,7 +23,7 @@ use crate::{
ScrollDelta, Size, TouchPhase, WindowParams,
};
use super::{X11Display, X11Window, X11WindowState, XcbAtoms};
use super::{super::SCROLL_LINES, X11Display, X11Window, X11WindowState, XcbAtoms};
use calloop::{
generic::{FdWrapper, Generic},
RegistrationToken,
@@ -221,12 +221,13 @@ impl X11Client {
}));
} else if event.detail >= 4 && event.detail <= 5 {
// https://stackoverflow.com/questions/15510472/scrollwheel-event-in-x11
let delta_x = if event.detail == 4 { 1.0 } else { -1.0 };
let scroll_direction = if event.detail == 4 { 1.0 } else { -1.0 };
let scroll_y = SCROLL_LINES * scroll_direction;
window.handle_input(PlatformInput::ScrollWheel(crate::ScrollWheelEvent {
position,
delta: ScrollDelta::Lines(Point::new(0.0, delta_x)),
delta: ScrollDelta::Lines(Point::new(0.0, scroll_y as f32)),
modifiers,
touch_phase: TouchPhase::default(),
touch_phase: TouchPhase::Moved,
}));
} else {
log::warn!("Unknown button press: {event:?}");