Fix(server): require left-button drag for desktop control of Android

桌面端(非触摸)控制 Android TV/盒子时,鼠标悬停会被客户端翻译成焦点移动,
鼠标划过画面就改变焦点。改为只在按住左键拖动时控制;触摸浏览器行为不变。

- MFC 主控:按 clientID 在主连接上解析并缓存客户端类型(新增线程安全的
  GetHostClientType,类型值在 m_cs 内读取);APK 主机的 WM_MOUSEMOVE 仅在
  MK_LBUTTON 按下时转发,不再每次移动都查主连接。
- Web 控制台:桌面 mousemove 对 Android 主机(优先使用服务端 isAndroidRemote,
  设备 os/clientType 只作兜底)只在左键按下时发 move;检查放在发送节流之后。
  touchstart/touchmove/touchend 未改动,触摸屏的单指移动、点按、拖拽、滚动
  和边缘手势保持原状。
- 安卓客户端未修改:TV 模式仍把带按键的 move 翻译成焦点导航,触摸浏览器
  发出的不带按键 move 继续可用。

验证:MFC Debug 服务端、Go 服务端构建通过;内联 JS 通过 node --check。

Model: deepseek-flash
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
yuanyuanxiangandClaude Code committed 2026-11-19 21:57:38 +01:00
1 parent 1320bb81a6
commit d6ea5fddea
5 files changed
+50

No files matched your search

+14
View File
@@ -7558,6 +7558,18 @@
sendMouse('up', x, y, 2);
}
// Android 主机(含 TV/盒子)会把悬停的 move 翻译成焦点移动;桌面鼠标
// 只在按住左键拖动时发送 move。优先用服务端下发的 isAndroidRemote
// (client_type === "APK"),设备列表字段只作兜底,保证与导航栏/直触
// 模式使用同一个判断。触摸路径走下面的 touch 处理器,不受影响。
function isAndroidHost() {
if (isAndroidRemote) return true;
if (!currentDevice) return false;
const os = String(currentDevice.os || '').toLowerCase();
const type = String(currentDevice.clientType || '').toLowerCase();
return os.includes('android') || type === 'apk';
}
// Desktop mouse handling
let lastMouseMove = 0;
let lastMouseX = 0, lastMouseY = 0;
@@ -7601,6 +7613,8 @@
lastMouseMove = now;
lastMouseX = pos.x;
lastMouseY = pos.y;
// Android(TV): 不按键的悬停不控制远程,只更新本地光标;按住左键拖动才发 move。
if (isAndroidHost() && !(e.buttons & 1)) return;
sendMouse('move', pos.x, pos.y, 0);
});