Fix: Make the Go web console wheel scroll correctly
The Go web server's mouse handler read deltaY as an int, so json.Unmarshal rejected the entire mouse message whenever the browser reported a fractional delta (Chrome's smooth scrolling splits one 100px notch into 33.33 + 33.33 + 33.34), and the wheel was dead while clicks and moves kept working. Treating every event as one notch was wrong the other way: it scrolled three to four times too far, and sub-pixel deltas from a touchpad truncated to zero. The server now accumulates the delta in notch units per client and injects WM_MOUSEWHEEL only once a whole notch is reached. The remainder is rounded, not truncated, so a float sum of 99.99px still lands on exactly one notch and the first notch fires halfway through a physical one, like native scrolling. The page forwards e.deltaMode so line and page based deltas convert correctly, and touchpad flings are capped at 20 notches per event. Verified against a live Go server with a connected client: 100px sends one packet, three 33.33px events send one, 53.33px sends one, sub-pixel events accumulate to none, and the wParam is -120 down / +120 up with SendToScreen returning no error. The MFC web console is untouched. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
c271911fcb
commit
6236ed1eb4
4 files changed
+156
-17
No files matched your search
@@ -63,6 +63,11 @@ type wsClient struct {
|
||||
user string // mirrors session username after login/resume
|
||||
termWatching string // device ID for an open web terminal session, "" otherwise
|
||||
|
||||
// wheelResidue carries the sub-notch remainder between wheel events so one
|
||||
// physical notch becomes exactly one WM_MOUSEWHEEL (see handleMouse). Only
|
||||
// the read loop that owns this client touches it.
|
||||
wheelResidue float64
|
||||
|
||||
// watchIDs is the set of devices this browser is streaming (the screen
|
||||
// wall watches several at once). Empty while on the device list.
|
||||
// Guarded by wsHub.mu.
|
||||
|
||||
Reference in new issue
Block a user