diff --git a/src/Surface.zig b/src/Surface.zig index a4a8d46df..e5e2b39bc 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2761,8 +2761,21 @@ pub fn scrollCallback( // that a wheel tick of 1 results in single scroll event. const yoff_adjusted: f64 = if (scroll_mods.precision) yoff - else - yoff * cell_size * self.config.mouse_scroll_multiplier; + else yoff_adjusted: { + // Round out the yoff to an absolute minimum of 1. macos tries to + // simulate precision scrolling with non precision events by + // ramping up the magnitude of the offsets as it detects faster + // scrolling. Single click (very slow) scrolls are reported with a + // magnitude of 0.1 which would normally require a few clicks + // before we register an actual scroll event (depending on cell + // height and the mouse_scroll_multiplier setting). + const yoff_max: f64 = if (yoff > 0) + @max(yoff, 1) + else + @min(yoff, -1); + + break :yoff_adjusted yoff_max * cell_size * self.config.mouse_scroll_multiplier; + }; // Add our previously saved pending amount to the offset to get the // new offset value. The signs of the pending and yoff should match