fix(computer): emit one full WHEEL_DELTA per libnut scroll tick#2575
fix(computer): emit one full WHEEL_DELTA per libnut scroll tick#2575quanru wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec4694cbb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await this.inputDriver.emitScrollDetents( | ||
| ux * LIBNUT_FALLBACK_DETENT_AMOUNT, | ||
| uy * LIBNUT_FALLBACK_DETENT_AMOUNT, | ||
| SCROLL_REPEAT_COUNT, |
There was a problem hiding this comment.
Preserve enough detents for edge-scroll fallback
When phased scrolling is unavailable and the libnut fallback is used (Windows/Linux, or macOS with the libnut keyboard driver), scrollToTop/scrollToBottom now emits only SCROLL_REPEAT_COUNT one-detent ticks. With the new platform-correct detent amount, that is roughly 10 wheel notches (about 1,000px by this file's LIBNUT_FALLBACK_PIXELS_PER_DETENT), whereas edge scrolls are documented and implemented in the phased path as a 50,000px boundary scroll; common long pages will stop far short of the top/bottom. The old Linux fallback effectively sent 100 notches, and the Windows fix should scale the number of detents rather than reducing the edge action to a single-screen-ish scroll.
Useful? React with 👍 / 👎.
Deploying midscene with
|
| Latest commit: |
9a63ffb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9de9d4ac.midscene.pages.dev |
| Branch Preview URL: | https://fix-computer-libnut-detents.midscene.pages.dev |
7244220 to
7e976ab
Compare
7e976ab to
4045343
Compare
Summary
ComputerInputDriver.emitScrollDetentsso scroll dispatch lives next to the rest of the input primitives.libnut.scrollMousecall (120 on Windows = oneWHEEL_DELTA, 1 elsewhere) and pace calls withLIBNUT_FALLBACK_TICK_DELAY_MSso blink doesn't coalesce them into a single tick.input-driver-scroll.test.tscovering per-call magnitude, pacing, horizontal pass-through, and destroy-mid-scroll rejection.Why
libnut.scrollMouse(x, y)is not a portable pixel API:ysemanticsMOUSEEVENTF_WHEEL'smouseData, where the unit isWHEEL_DELTA(= 120) per detentThe old fallback computed
ticks = ceil(distance / 100)and made a singlescrollMouse(0, ticks)call. On Windows that sendsmouseData < 120for any normal request — well below one detent — and Chromium'sWheelEventQueuesilently accumulates and drops it, which is exactly what we saw in Lark / Feishu Electron clients reporting "scroll did nothing". macOS still works because thephased-scrollhelper takes the path; Linux happens to work because 1 detent ≈ 1 notch already.Edge scrolls (
scrollToTopetc.) had the same problem in the libnut path: the unit vector was hard-coded as[0, 10]etc. — fine on Linux as 10 notches, near-useless on Windows asmouseData = 10.After this change, both the directional fallback and edge fallback go through
emitScrollDetents, which firesLIBNUT_FALLBACK_DETENT_AMOUNTper call —120on Windows,1everywhere else — and the destroy-mid-scroll rejection wired into the pending-input-delay set keeps shutdown clean.Test plan
pnpm run lintnpx nx test computer— 53/53 passing, including 4 new tests ininput-driver-scroll.test.tsnpx nx build computerRelated
fix/computer-scroll-win-fallback(commits905124883,d020e1de4) — those predated theComputerInputDriverrefactor on main; this PR is the rewrite.