@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
js 32 lines 1.04 KB
Raw
1 // QML library: keep geometry in compositor logical coordinates, including mixed-DPI outputs.
2 // eslint-disable-next-line no-unused-vars -- Exported by QML's JavaScript module loader.
3 function destination(windows, pid, title, relative) {
4 const matching = Array.from(windows).filter(
5 (window) => window.pid === pid && window.caption === title,
6 );
7 if (matching.length !== 1) throw new Error("Capture destination is ambiguous or missing");
8 const window = matching[0];
9 if (window.minimized) throw new Error("Capture destination is hidden");
10 const bounds = window.clientGeometry;
11 const { x, y, width, height } = relative;
12 if (
13 ![x, y, width, height].every(Number.isFinite) ||
14 x < 0 ||
15 y < 0 ||
16 width <= 0 ||
17 height <= 0 ||
18 x + width > 1.01 ||
19 y + height > 1.01
20 ) {
21 throw new Error("Invalid capture destination");
22 }
23 return {
24 window,
25 frame: {
26 x: bounds.x + x * bounds.width,
27 y: bounds.y + y * bounds.height,
28 width: width * bounds.width,
29 height: height * bounds.height,
30 },
31 };
32 }