Feature: Add window/region capture targets to remote_open

Pass the target HWND through the COMMAND_SCREEN_SPY token and send
COMMAND_SCREEN_ROI after session start, so MCP remote control can stream
just the target window or region instead of the scaled virtual desktop.
The session records the target kind, remote_mouse refuses a redundant
window_hwnd basis, and the cached resolution is refreshed per action so
resized windows keep mapping correctly. Cold starts now clear the stale
resolution cache used by the region handshake.
This commit is contained in:
yuanyuanxiang committed 2026-11-10 19:13:45 +01:00
1 parent 5501889d33
commit cdd9c56b3d
7 files changed
+445 -39

No files matched your search

+10 -2
View File
@@ -293,9 +293,15 @@ public:
bool BeginScreenCtrlOpen(uint64_t device_id, const std::string& sessionId);
// 子连接就绪(HasActiveSession && 分辨率到达)后调用:填 subCtx/分辨率并置 started。
// targeted=true 表示 remote_open 指定了 window_hwnd/region(帧不再是整屏)。
// false = 会话已被并发关闭(调用方应放弃本次 open)。
bool MarkScreenCtrlReady(uint64_t device_id, const std::string& sessionId,
context* subCtx, int screenW, int screenH);
context* subCtx, int screenW, int screenH,
bool targeted = false);
// 会话是否只推窗口/区域:此时归一化坐标已经相对目标帧,remote_mouse 的 window_hwnd
// 基准(相对整虚拟桌面)不再适用。须在 BeginScreenCtrlAction 之后调用。
bool IsScreenCtrlTargeted(uint64_t device_id, const std::string& sessionId);
// 注入前登记(校验 sessionId/started/!busy/!closed)。输出 subCtx/screenW/H。
// 注入期间 busy=true,保证 close/sweep/断线不与注入并发擦会话(镜像终端 busy 模式,
@@ -840,8 +846,10 @@ private:
bool closed = false; // 注入期间屏幕子连接已断(由注入线程收尾)
time_t lastActiveAt = 0; // idle 回收用(秒)
std::chrono::steady_clock::time_point startedAt = std::chrono::steady_clock::now(); // P11
int screenW = 0; // 物理捕获分辨率(来自 TOKEN_BITMAPINFO)
int screenW = 0; // 抓屏帧宽度(TOKEN_BITMAPINFO;目标窗口/区域时为裁剪后尺寸)
int screenH = 0;
// remote_open 指定了 window_hwnd/region:帧是窗口/区域而非整屏,归一化坐标已相对该帧。
bool targeted = false;
// P10-C 键鼠锁定:inputBlocked 是服务端认为的锁定状态(唯一真相,用于强制解锁);
// blockUntil 是自动解锁期限;blockAutoReleased 待下一次 remote_block_input 上报。
bool inputBlocked = false;