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

+16
View File
@@ -13580,6 +13580,22 @@ context* CMy2015RemoteDlg::FindHostByClientID(uint64_t clientID)
return ctx;
}
bool CMy2015RemoteDlg::GetHostClientType(uint64_t clientID, CString& clientType)
{
clientType.Empty();
bool found = false;
EnterCriticalSection(&m_cs);
auto it = m_ClientIndex.find(clientID);
if (it != m_ClientIndex.end() && it->second < m_HostList.size()) {
if (context* ctx = m_HostList[it->second]) {
clientType = ctx->GetAdditionalData(RES_CLIENT_TYPE);
found = true;
}
}
LeaveCriticalSection(&m_cs);
return found;
}
uint64_t CMy2015RemoteDlg::FindClientIDByIP(const std::string& ip)
{
CString clientIP(ip.c_str());
+3
View File
@@ -485,6 +485,9 @@ public:
std::vector<DllInfo*> m_DllList;
context* FindHostByIP(const std::string& ip);
context* FindHostByClientID(uint64_t clientID); // 线程安全:通过 clientID 精确查主连接
// 线程安全:在 m_cs 内读取并返回值,避免调用方拿到裸指针后再访问附加数据;
// 找不到主连接时返回 false。
bool GetHostClientType(uint64_t clientID, CString& clientType);
uint64_t FindClientIDByIP(const std::string& ip); // 线程安全:在锁内获取ID
void InjectTinyRunDll(const std::string& ip, int pid);
NOTIFYICONDATA m_Nid;
+14
View File
@@ -3442,7 +3442,21 @@ BOOL CScreenSpyDlg::PreTranslateMessage(MSG* pMsg)
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
SendScaledMouseMessage(pMsg, true);
break;
case WM_MOUSEMOVE:
// Android(含 TV/盒子)把悬停的 mousemove 翻译成焦点移动;MFC 控制端只在
// 按住左键拖动时转发,避免鼠标划过画面时远程焦点乱跳。触摸屏浏览器的输入
// 走 Web 前端的 touch 处理器,不经过这里。
if (m_bIsCtrl) {
if (m_androidHost < 0 && m_ClientID != 0 && g_2015RemoteDlg) {
CString clientType;
if (g_2015RemoteDlg->GetHostClientType(m_ClientID, clientType))
m_androidHost = clientType.CompareNoCase(_T("APK")) == 0 ? 1 : 0;
}
if (m_androidHost == 1 && !(pMsg->wParam & MK_LBUTTON))
break;
}
SendScaledMouseMessage(pMsg, true);
break;
case WM_MOUSEWHEEL: {
+3
View File
@@ -208,6 +208,9 @@ class CScreenSpyDlg : public DialogBase
DECLARE_DYNAMIC(CScreenSpyDlg)
CToolbarDlg* m_pToolbar = nullptr;
CMy2015RemoteDlg* m_pParent = nullptr;
// -1=尚未解析, 0=非 Android, 1=Android(APK)。只在 UI 线程读写:PreTranslateMessage
// 首次用到时解析并缓存,避免每次 mousemove 都查主连接。
int m_androidHost = -1;
public:
CStatusInfoWnd* m_pStatusInfoWnd = nullptr;
+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);
});