Feature: Capture the virtual desktop for multi-monitor remote control
The MCP Observe/Act loop requires screenshots and mouse injection to share one coordinate space. Previously the client sent only the primary monitor while injection used virtual-desktop coordinates, so multi-monitor hosts were rejected outright. - Client: COMMAND_SCREEN_SPY param buffer[11] (wire index 12) now forces whole-virtual-desktop GDI capture; preview JPEGs also cover the virtual desktop including negative origins. - Server: advertise CLIENT_CAP_VIRTUAL_DESKTOP, gate multi-monitor remote control on that capability, and pass the flag when starting the session. Linux stays exempt (X root capture/injection are already consistent).
This commit was merged in pull request #7.
This commit is contained in:
1 parent
5bb24d714a
commit
5eb44307ee
11 files changed
+93
-48
No files matched your search
+11
-11
@@ -46,19 +46,19 @@ int GetJpegEncoderClsid(CLSID& clsid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 抓主屏到 24bpp Bitmap,目标尺寸已等比换算。
|
||||
// 抓整个虚拟桌面到 24bpp Bitmap,目标尺寸已等比换算。
|
||||
// 虚拟桌面原点不一定是 (0,0):主屏左侧/上方存在显示器时 SM_X/YVIRTUALSCREEN 为负,
|
||||
// 必须作为 StretchBlt 的源点,否则抓到的只是主屏那一块(与注入坐标系不一致)。
|
||||
// 返回新分配的 Bitmap*,失败返回 nullptr。调用者负责 delete。
|
||||
Bitmap* GrabPrimaryScaled(int targetW, int targetH)
|
||||
Bitmap* GrabDesktopScaled(int targetW, int targetH)
|
||||
{
|
||||
HDC hScreen = GetDC(NULL);
|
||||
if (!hScreen) return nullptr;
|
||||
|
||||
int srcX = GetSystemMetrics(SM_XVIRTUALSCREEN); // 主屏左上 — 仅取主屏时用 0,0
|
||||
int srcX = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||
int srcY = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||
(void)srcX; (void)srcY;
|
||||
|
||||
int srcW = GetSystemMetrics(SM_CXSCREEN);
|
||||
int srcH = GetSystemMetrics(SM_CYSCREEN);
|
||||
int srcW = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
int srcH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
if (srcW <= 0 || srcH <= 0) {
|
||||
ReleaseDC(NULL, hScreen);
|
||||
return nullptr;
|
||||
@@ -79,7 +79,7 @@ Bitmap* GrabPrimaryScaled(int targetW, int targetH)
|
||||
SetStretchBltMode(hMem, HALFTONE);
|
||||
SetBrushOrgEx(hMem, 0, 0, NULL);
|
||||
BOOL bb = StretchBlt(hMem, 0, 0, targetW, targetH,
|
||||
hScreen, 0, 0, srcW, srcH, SRCCOPY | CAPTUREBLT);
|
||||
hScreen, srcX, srcY, srcW, srcH, SRCCOPY | CAPTUREBLT);
|
||||
|
||||
SelectObject(hMem, oldBmp);
|
||||
|
||||
@@ -117,8 +117,8 @@ int CaptureAndEncodePreview(int maxWidth, int quality,
|
||||
if (quality < 1) quality = 1;
|
||||
if (quality > 100) quality = 100;
|
||||
|
||||
int srcW = GetSystemMetrics(SM_CXSCREEN);
|
||||
int srcH = GetSystemMetrics(SM_CYSCREEN);
|
||||
int srcW = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
int srcH = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
if (srcW <= 0 || srcH <= 0) return SCREEN_PREVIEW_CAPTURE_FAILED;
|
||||
|
||||
// 等比缩放,禁止放大
|
||||
@@ -131,7 +131,7 @@ int CaptureAndEncodePreview(int maxWidth, int quality,
|
||||
if (targetW < 2) targetW = 2;
|
||||
if (targetH < 2) targetH = 2;
|
||||
|
||||
Bitmap* bmp = GrabPrimaryScaled(targetW, targetH);
|
||||
Bitmap* bmp = GrabDesktopScaled(targetW, targetH);
|
||||
if (!bmp) return SCREEN_PREVIEW_CAPTURE_FAILED;
|
||||
|
||||
CLSID clsid;
|
||||
|
||||
Reference in new issue
Block a user