Skip to content

fix: convert XTest fallback scroll units to wheel notches - #22

Draft
possibilities wants to merge 2 commits into
kernel:masterfrom
possibilities:fix/xtest-scroll-fallback-units
Draft

possibilities wants to merge 2 commits into
kernel:masterfrom
possibilities:fix/xtest-scroll-fallback-units

Conversation

@possibilities

Copy link
Copy Markdown

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

  • Updated against current Kernel master without rewriting the existing branch
  • Full server go test -race ./... and go vet ./... passed
  • Added unit coverage for signed deltas, reversals, independent axes, resets, modifier isolation, and integer limits
  • Added opt-in real-XTest tests and wired them into server CI with a disposable Xvfb display
  • All 10 integration cases passed 20 consecutive race-enabled runs; the tests reproduce both the original 120-click bug and the physical-Ctrl remainder bug

The vendored driver sync discussed in #17 is a separate patch. This PR deliberately does not close the multi-part issue.

possibilities and others added 2 commits September 1, 2026 07:45
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

No deployments
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.

1 participant