Files
SimpleRemoter/macos/ScreenPreview.h
T
yuanyuanxianganddeepseek-flash 06b93f7bdb Feat(client): complete the macOS feature set (phase 0 and 1)
Phase 0 makes implementations that already existed reachable. macOS now
declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a
new bit and Linux declares it too. SystemManager was dead code -- its
constructor took a second argument and it did not derive IOCPManager, so the
sub-connection skeleton could never instantiate it -- and now matches the
createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a
sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user,
so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally
answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC
for exec_command / terminal_* and for SupportsProcess() for kill_process, so
an old build gets "client is too old" instead of a command nobody answers;
kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the
terminal works on macOS, but the probe uses GNU-only base64 -w.

Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage,
scales and ships BGRX for the server to encode, and the capability is only
declared when preflight or a real capture says the display is readable.
ActivityHistory samples the frontmost layer-0 window once a second and prints
the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now
consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the
receive thread raises a flag, the capture thread -- which owns the encoder --
consumes it and puts it back if the frame never went out. The macOS quality
level persists in NSUserDefaults because main.mm rewrites config.conf.

Linux client and Debug x64 server rebuild green; check_platform_table PASS.
Not built or run on a Mac.

Co-Authored-By: deepseek-flash
2026-11-14 13:30:50 +01:00

21 lines
1.1 KiB
C++

#pragma once
// 屏幕预览(COMMAND_SCREEN_PREVIEW_REQ)—— macOS 端一次性抓屏
//
// 与 linux/ScreenPreview.h、Windows 端 client/ScreenPreview.h 对应:服务端双击在线主机
// 时索取一张缩略图。macOS 没有可依赖的 JPEG 编码库(ImageIO 能编,但走的是另一套
// 颜色/尺寸语义,与 Windows 的 GDI+ 输出不一致),所以这里只做 抓屏 → 等比缩放 →
// BGRA 原始像素,由服务端在 IO 线程统一编码成 JPEG(下游只认 JPEG 一种格式)。
#include <vector>
class ScreenPreview
{
public:
// 本机当前能否截图:有主显示器且已授予录屏权限。
// 服务端按 CLIENT_CAP_SCREEN_PREVIEW 决定要不要下发预览请求,能力位就取自它。
static bool IsAvailable();
// 抓主屏并等比缩放到 maxWidth 以内(不放大、高不超过 1080),返回 ScreenPreviewStatus。
// out 为自上而下逐行、每像素 B,G,R,X 四字节(X=0xFF),无行首填充。
static int Capture(int maxWidth, std::vector<unsigned char>& out, int& outW, int& outH);
};