From 32f5677a9482776a013137f04953f313dc81bd20 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 27 Jan 2026 08:34:31 -0800 Subject: [PATCH] macos: slow down inspector trackpad (precision) scrolling --- .../Sources/Ghostty/Surface View/InspectorView.swift | 10 ++-------- src/apprt/embedded.zig | 11 +++++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/InspectorView.swift b/macos/Sources/Ghostty/Surface View/InspectorView.swift index 2a004ac76..e8eaf3a80 100644 --- a/macos/Sources/Ghostty/Surface View/InspectorView.swift +++ b/macos/Sources/Ghostty/Surface View/InspectorView.swift @@ -269,16 +269,10 @@ extension Ghostty { // Builds up the "input.ScrollMods" bitmask var mods: Int32 = 0 - var x = event.scrollingDeltaX - var y = event.scrollingDeltaY + let x = event.scrollingDeltaX + let y = event.scrollingDeltaY if event.hasPreciseScrollingDeltas { mods = 1 - - // We do a 2x speed multiplier. This is subjective, it "feels" better to me. - x *= 2; - y *= 2; - - // TODO(mitchellh): do we have to scale the x/y here by window scale factor? } // Determine our momentum value diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index b4ad7f885..a035caf62 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -1133,15 +1133,18 @@ pub const Inspector = struct { yoff: f64, mods: input.ScrollMods, ) void { - _ = mods; - self.queueRender(); cimgui.c.ImGui_SetCurrentContext(self.ig_ctx); const io: *cimgui.c.ImGuiIO = cimgui.c.ImGui_GetIO(); + + // For precision scrolling (trackpads), the values are in pixels which + // scroll way too fast. Scale them down to approximate discrete wheel + // notches. imgui expects 1.0 to scroll ~5 lines of text. + const scale: f64 = if (mods.precision) 0.1 else 1.0; cimgui.c.ImGuiIO_AddMouseWheelEvent( io, - @floatCast(xoff), - @floatCast(yoff), + @floatCast(xoff * scale), + @floatCast(yoff * scale), ); }