mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 22:01:47 +03:00
macos: fix minimum scroll wheel tick
macos generates fractional distance values for the mouse wheel, with one tick starting at 0.1. We were truncating this to a 0 row move, which meant that you'd need to build up some acceleration to move the rows when all you really wanted was a single tick. This commit changes things so that we round up to at least 1.0 in this situation.
This commit is contained in:
parent
2f6f3ed933
commit
9670fc3fdf
@ -36,6 +36,14 @@ pub fn use_ime(enable: bool) {
|
|||||||
USE_IME.store(enable, Ordering::Relaxed);
|
USE_IME.store(enable, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn round_away_from_zero(value: f64) -> i16 {
|
||||||
|
if value > 0. {
|
||||||
|
value.max(1.).round() as i16
|
||||||
|
} else {
|
||||||
|
value.min(-1.).round() as i16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct NSRange(cocoa::foundation::NSRange);
|
struct NSRange(cocoa::foundation::NSRange);
|
||||||
|
|
||||||
@ -999,9 +1007,9 @@ impl WindowView {
|
|||||||
let vert_delta = unsafe { nsevent.scrollingDeltaY() };
|
let vert_delta = unsafe { nsevent.scrollingDeltaY() };
|
||||||
let horz_delta = unsafe { nsevent.scrollingDeltaX() };
|
let horz_delta = unsafe { nsevent.scrollingDeltaX() };
|
||||||
let kind = if vert_delta.abs() > horz_delta.abs() {
|
let kind = if vert_delta.abs() > horz_delta.abs() {
|
||||||
MouseEventKind::VertWheel(vert_delta as i16)
|
MouseEventKind::VertWheel(round_away_from_zero(vert_delta))
|
||||||
} else {
|
} else {
|
||||||
MouseEventKind::HorzWheel(horz_delta as i16)
|
MouseEventKind::HorzWheel(round_away_from_zero(horz_delta))
|
||||||
};
|
};
|
||||||
Self::mouse_common(this, nsevent, kind);
|
Self::mouse_common(this, nsevent, kind);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user