Feature: Draw the remote cursor in the web desktop out of control mode
Screen frames are captured without the pointer composed in (GDI SRCCOPY, DXGI), so browsers only ever knew the cursor's shape index and could show a cursor just in control mode, where the local pointer stands in for the remote one. Both servers now relay the cursor position that every per-frame header already carries: shape changes go out immediately, position changes at most every 50 ms, and an unchanged cursor is re-sent once a second so a viewer that joins while the pointer is idle still learns where it is. The page hides the local pointer and draws the remote cursor at its true position while out of control mode; entering control mode restores exactly the old behaviour (remote-shaped CSS cursor on desktop, touchpad pointer on touch). A server that never sends x/y leaves the page on its previous fallback. The C++ server broadcasts from the per-frame path, so header-only frames keep a static desktop's cursor fresh; the Go hub dedups and throttles before fanning out. Tests cover the throttle/refresh rules and the relayed payload. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
6236ed1eb4
commit
bfb17d0d25
12 files changed
+322
-65
No files matched your search
+16
-5
@@ -418,13 +418,24 @@ func (h *MyHandler) handleScreenFrame(ctx *connection.Context, data []byte, alwa
|
||||
}
|
||||
// data[0] is the token; the 11-byte header sits at data[1..12].
|
||||
const skip = 1 + protocol.ScreenFrameHeaderLen
|
||||
if len(data) <= skip {
|
||||
if len(data) < skip {
|
||||
return // truncated header
|
||||
}
|
||||
// Cursor position + index live in the per-frame header: [1]=algorithm,
|
||||
// [2..9]=POINT (x,y int32 LE), [10]=cursor index. Publish before the heavy
|
||||
// frame work so the browser sees cursor updates even if we drop the frame.
|
||||
// The position is in the captured frame's coordinate space, which is also
|
||||
// the browser canvas space — the overlay can draw it as-is.
|
||||
//
|
||||
// The client also sends header-only packets (no bitmap change) at the frame
|
||||
// rate, so this keeps a static desktop's cursor fresh for non-controlling
|
||||
// viewers; those packets carry no video and are dropped right after.
|
||||
cursorX := int(int32(binary.LittleEndian.Uint32(data[2:6])))
|
||||
cursorY := int(int32(binary.LittleEndian.Uint32(data[6:10])))
|
||||
h.hub.PublishCursor(deviceID, data[10], cursorX, cursorY)
|
||||
if len(data) == skip {
|
||||
return
|
||||
}
|
||||
// Cursor index lives at the last byte of the small per-frame header
|
||||
// (offset 1 + 1 + 8 = 10). Publish before the heavy frame work so the
|
||||
// browser sees cursor updates even if we end up dropping frames later.
|
||||
h.hub.PublishCursor(deviceID, data[10])
|
||||
|
||||
video := data[skip:]
|
||||
// 按首字节嗅探 H.264 / AV1,分发到对应的 keyframe 探测器。浏览器侧用同样方式
|
||||
|
||||
@@ -21,15 +21,15 @@ type recordedFrame struct {
|
||||
func (r *frameRecorder) OnScreenFrame(deviceID string, packet []byte, isKeyframe bool) {
|
||||
r.frames = append(r.frames, recordedFrame{deviceID, packet, isKeyframe})
|
||||
}
|
||||
func (r *frameRecorder) OnDeviceOnline(hub.DeviceInfo) {}
|
||||
func (r *frameRecorder) OnDeviceOffline(string) {}
|
||||
func (r *frameRecorder) OnDeviceUpdate(string, int, string) {}
|
||||
func (r *frameRecorder) OnResolutionChange(string, int, int) {}
|
||||
func (r *frameRecorder) OnCursorChange(string, byte) {}
|
||||
func (r *frameRecorder) OnClipboardText(string, string) {}
|
||||
func (r *frameRecorder) OnTerminalReady(string, bool) {}
|
||||
func (r *frameRecorder) OnTerminalData(string, []byte) {}
|
||||
func (r *frameRecorder) OnTerminalClosed(string, string) {}
|
||||
func (r *frameRecorder) OnDeviceOnline(hub.DeviceInfo) {}
|
||||
func (r *frameRecorder) OnDeviceOffline(string) {}
|
||||
func (r *frameRecorder) OnDeviceUpdate(string, int, string) {}
|
||||
func (r *frameRecorder) OnResolutionChange(string, int, int) {}
|
||||
func (r *frameRecorder) OnCursorChange(string, byte, int, int) {}
|
||||
func (r *frameRecorder) OnClipboardText(string, string) {}
|
||||
func (r *frameRecorder) OnTerminalReady(string, bool) {}
|
||||
func (r *frameRecorder) OnTerminalData(string, []byte) {}
|
||||
func (r *frameRecorder) OnTerminalClosed(string, string) {}
|
||||
|
||||
// TestOnReceiveRelaysKeyframeToken guards the forced-IDR recovery path: when
|
||||
// the browser asks for a keyframe, the client replies with TOKEN_KEYFRAME.
|
||||
|
||||
Reference in new issue
Block a user