fix: convert XTest fallback scroll units to wheel notches - #22
Draft
possibilities wants to merge 2 commits into
Draft
possibilities wants to merge 2 commits into
possibilities wants to merge 2 commits into
Conversation
When the xf86-input-neko driver is enabled, scroll deltas are in its scroll units, 120 per wheel notch (pkg/xinput/types.go). If the write to the driver socket fails, Scroll falls back to XTest, which clicks a wheel button once per unit, so a single notch replays as 120 clicks and a coalesced gesture as thousands. Convert the delta to whole notches on that fallback path only, through a new xorg.ScrollUnits that carries the sub-notch remainder so slow scrolling still accumulates. xorg.Scroll keeps upstream's semantics, where the delta is a click count, and still serves deployments that run without the driver, so their scrolling is unchanged. Page scrolling and Control-held zooming accumulate separately, so a remainder left by one cannot discharge as a notch of the other, and ResetKeys discards both. The arithmetic is plain Go and unit tested. The fallback path itself needs a running X server and stays uncovered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merge current Kernel master without rewriting existing branch history. Preserve driver-disabled click-count behavior, carry fractional scroll units safely, and verify real XTest events in CI.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #17 (the XTest fallback part).
What changed
When the input driver is enabled but its socket write fails, convert the 120-unit scroll deltas into whole wheel clicks. Carry sub-notch motion across calls, keeping page scrolling and Control-held zooming separate.
The accumulator uses the effective X server Control state, so this also works for legacy clients that send Ctrl keydown separately. ResetKeys clears both remainders, and the arithmetic avoids overflow when adding a remainder to a large delta.
The driver-disabled path keeps its existing click-count semantics. Successful driver writes still receive the original scroll units.
Verification
go test -race ./...andgo vet ./...passedThe vendored driver sync discussed in #17 is a separate patch. This PR deliberately does not close the multi-part issue.