Skip to content

Conversation

evan-goode
Copy link
Contributor

Fixes a bug where VALUE120 scroll events with value < 1 line would always scroll a full line, leading to strange-feeling scrolling behavior on smooth-scrolling input devices.

Explanation:

        // VALUE120 events are "discrete" in that they scroll lines, not pixels.
        // But each VALUE120 event of value `v` represents a fraction of a
        // line, specifically `v` 120ths of a line.

        // GLFWscrollfun does not handle non-highres scroll events with
        // non-integer value. We could use `highres` for VALUE120 events, but
        // that would be wrong since the units should be interpreted as
        // fractional lines, not pixels.

        // So instead, we accumulate discrete events until we have at least one
        // full line to scroll, and then call the GLFWscrollfun to scroll entire
        // lines.

@kovidgoyal
Copy link
Owner

The correct fix for this would be to pass the fact that these are 120th of line units in the flags parameter of GLFWscrollfun() and then change the code in mouse.c that handles them to use that information to actually scroll by 120th of a line. IIRC only the first four bits of flags is currently used so you can use bit 5 for it.

@evan-goode evan-goode force-pushed the evan-goode/accumulate-value120 branch 2 times, most recently from 5d25a94 to 65cdd9e Compare October 19, 2025 15:17
@evan-goode
Copy link
Contributor Author

The correct fix for this would be to pass the fact that these are 120th of line units in the flags parameter of GLFWscrollfun() and then change the code in mouse.c that handles them to use that information to actually scroll by 120th of a line. IIRC only the first four bits of flags is currently used so you can use bit 5 for it.

Thanks, done. I didn't look at first and I assumed the GLFWscrollfun was some library code.

I realized that we currently do not handle the case when the two scroll axes are different types, e.g. one is continuous and another is discrete. But that would only be a problem with some very small minority of pointing devices.

@kovidgoyal
Copy link
Owner

I dont quite follow the logic. In mouse.c you are treating a VALUE120
value as pixels (the logic is identical for high res and value120
values? For value120 value shouldnt this be

s = offset * cell_height / 120

rather than

s = offset / cell_height

In other words a value of 120 should cause a scroll by one line.

@evan-goode evan-goode force-pushed the evan-goode/accumulate-value120 branch from 65cdd9e to 80a9bdb Compare October 20, 2025 13:33
@evan-goode
Copy link
Contributor Author

You're right, my bad. How's that?

@kovidgoyal kovidgoyal merged commit 8630f21 into kovidgoyal:master Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants