Skip to content

mouse-scroll-multiplier should allow setting precision multiplier #8670

Description

@mitchellh

Discussion: #8649

You can see in the source that the mouse-scroll-multiplier config is unused in the precision scroll path:

ghostty/src/Surface.zig

Lines 2805 to 2826 in a32d498

// If we have precision scroll, yoff is the number of pixels to scroll. In non-precision
// scroll, yoff is the number of wheel ticks. Some mice are capable of reporting fractional
// wheel ticks, which don't necessarily get reported as precision scrolls. We normalize all
// scroll events to pixels by multiplying the wheel tick value and the cell size. This means
// that a wheel tick of 1 results in single scroll event.
const yoff_adjusted: f64 = if (scroll_mods.precision)
yoff
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;
};

We don't want to blindly apply it to the precision case because the default value of 3 will result in a speed that is way too fast. Dividing by 3 to normalize the default is equally ugly and also just arbitrary...

Instead, we should allow a separate precision vs non-precision scroll multiplier. I propose the following:

# Apply everywhere
mouse-scroll-multiplier = 3

# Apply separately
mouse-scroll-multiplier = precision:2,discrete:3

# Apply one, default other
mouse-scroll-multiplier = precision:2

"Precision" and "discrete" are not strictly opposite ("continuous" would be better for example) but precision scrolling is a common term used to describe mouse inputs that can report continuous values, so I think it hits better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyA well-scoped, approachable issue for someone looking to contribute.inputKeyboard or mouse input

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions