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:
yuanyuanxianganddeepseek-flash committed 2026-10-26 17:44:13 +01:00
1 parent 6236ed1eb4
commit bfb17d0d25
12 files changed
+322 -65

No files matched your search

+29 -8
View File
@@ -1415,6 +1415,31 @@ VOID CScreenSpyDlg::DrawFirstScreen(void)
PostMessage(WM_PAINT);//触发WM_PAINT消息
}
// 把远程光标的位置/类型同步给 Web 客户端。抓屏画面本身不含光标(GDI/DXGI 都不合成),
// 非控制态的浏览器靠这条消息在画面上自己画一个光标。
// 类型变化 → 立即发(force=true);
// 位置变化 → 50ms 节流;
// 完全静止 → 每秒重发一次,让刚打开页面的观察者也能立刻看到光标位置
// (否则要等远程鼠标下一次移动)。
void CScreenSpyDlg::BroadcastCursorToWeb(bool force)
{
if (!m_bIsWebSession || !WebService().IsRunning()) return;
ULONGLONG now = GetTickCount64();
ULONGLONG since = now - m_nLastCursorBroadcast;
bool reshaped = force || m_bCursorIndex != m_bBroadcastCursorIndex;
bool moved = m_ClientCursorPos.x != m_ptBroadcastCursor.x ||
m_ClientCursorPos.y != m_ptBroadcastCursor.y;
if (!reshaped) {
if (since < 50) return; // 位置变化节流
if (!moved && since < 1000) return; // 静止时每秒兜底一次
}
m_nLastCursorBroadcast = now;
m_bBroadcastCursorIndex = m_bCursorIndex;
m_ptBroadcastCursor = m_ClientCursorPos;
WebService().BroadcastCursor(m_ClientID, m_bCursorIndex,
(int)m_ClientCursorPos.x, (int)m_ClientCursorPos.y);
}
VOID CScreenSpyDlg::DrawNextScreenDiff(bool keyFrame)
{
//该函数不是直接画到屏幕上,而是更新一下变化部分的屏幕数据然后调用
@@ -1452,10 +1477,6 @@ VOID CScreenSpyDlg::DrawNextScreenDiff(bool keyFrame)
m_bCursorIndex = m_ContextObject->InDeCompressedBuffer.GetBuffer(2+sizeof(POINT))[0];
if (bOldCursorIndex != m_bCursorIndex) {
bChange = TRUE;
// 通知 Web 客户端光标变化 (只有 Web 会话的对话框才广播)
if (m_bIsWebSession && WebService().IsRunning()) {
WebService().BroadcastCursor(m_ClientID, m_bCursorIndex);
}
if (m_bIsCtrl && !m_bIsTraceCursor) {//替换指定窗口所属类的WNDCLASSEX结构
HCURSOR cursor;
if (m_bCursorIndex == 254) { // -2: 使用自定义光标
@@ -1473,6 +1494,8 @@ VOID CScreenSpyDlg::DrawNextScreenDiff(bool keyFrame)
#endif
}
}
// 通知 Web 客户端光标位置/类型(内部按类型变化/位置节流/每秒兜底决定是否真发)
BroadcastCursorToWeb(false);
// 屏幕是否变化
if (NextScreenLength > 0) {
@@ -1638,11 +1661,9 @@ VOID CScreenSpyDlg::DrawScrollFrame()
m_bCursorIndex = m_ContextObject->InDeCompressedBuffer.GetBuffer(2 + sizeof(POINT))[0];
if (bOldCursorIndex != m_bCursorIndex) {
bChange = TRUE;
// 通知 Web 客户端光标变化 (只有 Web 会话的对话框才广播)
if (m_bIsWebSession && WebService().IsRunning()) {
WebService().BroadcastCursor(m_ClientID, m_bCursorIndex);
}
}
// 通知 Web 客户端光标位置/类型(内部按类型变化/位置节流/每秒兜底决定是否真发)
BroadcastCursorToWeb(false);
// 读取滚动参数
LPBYTE buffer = m_ContextObject->InDeCompressedBuffer.GetBuffer(ulHeadLength);