Fix: Release remotely injected keys the controller never lifted
A browser or native controller can lose a keyup (window blur, tab switch, browser shortcut, in-app dialog, disconnect). The remote OS then keeps Ctrl/Shift/Alt down, later keystrokes turn into shortcuts, and only pressing the modifier again clears it. The web console now tracks the keys it sent down and releases them on blur, visibilitychange, pagehide, dialog, control off, device switch and disconnect; the next keydown/mousedown/wheel reconciles tracked modifiers against the event's real modifier state. Keys held when the socket drops are stashed and released once the screen session is confirmed after reconnect, tagged with the device so they never reach another host. The Ctrl+V bridge flag is reset wherever its physical keyup can be lost. The Windows client tracks injected keys by VK + scan code + extended bit so right-hand modifiers release the key that was pressed, and releases them on session teardown and reconnect; the Linux agent does the same on teardown with XTestFakeKeyEvent. Verified with a 20-scenario headless Chrome harness, group filter regressions, node --check, go build/vet/test, a Debug client build and the WSL Linux build. Not exercised against a real controller and host; the macOS agent is unchanged. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
6fd6e9cbaa
commit
5bb24d714a
4 files changed
+303
-11
No files matched your search
@@ -19,6 +19,8 @@ bool IsWindows8orHigher();
|
||||
|
||||
#include "ScreenSpy.h"
|
||||
#include "ScreenCapture.h"
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
|
||||
// WASAPI 前向声明 (COM 接口)
|
||||
struct IMMDevice;
|
||||
@@ -61,6 +63,13 @@ public:
|
||||
VOID SendNextScreen(const char* szBuffer, ULONG ulNextSendLength);
|
||||
|
||||
VOID ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
|
||||
// 已注入、尚未收到 keyup 的按键。主控端丢 keyup(浏览器失焦/断线、控制端
|
||||
// 切换窗口)时远程系统会把 Ctrl/Shift/Alt 一直当成按下,表现为"打字很怪"。
|
||||
// 会话结束或重连时在这里补发 keyup 兜底。
|
||||
// keyId 编码 VK+扫描码+扩展位(见 MakeInjectedKeyId):左右 Shift/Ctrl/Alt
|
||||
// 的 VK 相同,必须按注入时的同一身份补发,否则抬起的是另一边的键。
|
||||
void TrackInjectedKey(DWORD keyId, bool down);
|
||||
void ReleaseInjectedKeys();
|
||||
UserParam *m_pUserParam = NULL;
|
||||
INT_PTR m_ptrUser;
|
||||
HDESK g_hDesk;
|
||||
@@ -118,6 +127,8 @@ public:
|
||||
POINT m_rclickPoint; // 右键点击坐标
|
||||
HWND m_rclickWnd; // 右键窗口
|
||||
int m_nSwitchWindowIndex = 0; // 切换窗口索引
|
||||
std::set<DWORD> m_InjectedKeys; // 注入后未收到 keyup 的键(VK+扫描码+扩展位)
|
||||
std::mutex m_InjectedKeysMutex; // ProcessCommand 与析构/重连可能并发
|
||||
|
||||
// ========== 系统音频捕获 (WASAPI Loopback) ==========
|
||||
volatile BOOL m_bAudioThreadRunning = FALSE;// 音频线程运行标志(独立于视频线程)
|
||||
|
||||
Reference in new issue
Block a user