From 154169b054a4bec21127a963d9164b364c518d9c Mon Sep 17 00:00:00 2001 From: Aditya Bhargava Date: Thu, 19 Mar 2026 02:13:45 -0400 Subject: [PATCH 1/2] Fix speedy high-resolution scrolling on Linux Enforcing an absolute minimum of 1 for scroll events causes differing scroll speeds between high-resolution and standard scroll wheels on Linux. Since this was added to handle MacOS's precision scrolling emulation, this patch alters the behaviour so that the absolute minimum is only enforced on MacOS. Fixes #11648. --- src/Surface.zig | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 086c0fc8e..cea0065fc 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3424,19 +3424,24 @@ pub fn scrollCallback( const yoff_adjusted: f64 = if (scroll_mods.precision) yoff * self.config.mouse_scroll_multiplier.precision 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); + if (comptime builtin.target.os.tag.isDarwin()) { + // 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.discrete; + break :yoff_adjusted yoff_max * cell_size * self.config.mouse_scroll_multiplier.discrete; + } + else { + break :yoff_adjusted yoff * cell_size * self.config.mouse_scroll_multiplier.discrete; + } }; // Add our previously saved pending amount to the offset to get the From 5871a2d4f079c13c07997ac5b2938aabe053ea55 Mon Sep 17 00:00:00 2001 From: Aditya Bhargava Date: Mon, 27 Apr 2026 16:27:58 -0400 Subject: [PATCH 2/2] zig-fmt cleanup --- src/Surface.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index cea0065fc..5d16f3326 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3438,8 +3438,7 @@ pub fn scrollCallback( @min(yoff, -1); break :yoff_adjusted yoff_max * cell_size * self.config.mouse_scroll_multiplier.discrete; - } - else { + } else { break :yoff_adjusted yoff * cell_size * self.config.mouse_scroll_multiplier.discrete; } };