mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 14:00:29 +00:00
macos: slow down inspector trackpad (precision) scrolling
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user