| 1 | // PID comes from the bus daemon, not from the caller. Never focus a different T3 process. |
| 2 | export function findCaptureDestination(windows, pid, title) { |
| 3 | const owned = windows.filter((window) => window.get_pid() === pid); |
| 4 | const matching = owned.filter((window) => window.get_title() === title); |
| 5 | if (matching.length === 1) return matching[0]; |
| 6 | return owned.length === 1 ? owned[0] : undefined; |
| 7 | } |
| 8 | |
| 9 | export function captureDestinationFrame(relative, bounds) { |
| 10 | const { x, y, width, height } = relative; |
| 11 | if ( |
| 12 | ![x, y, width, height].every(Number.isFinite) || |
| 13 | x < 0 || |
| 14 | y < 0 || |
| 15 | width <= 0 || |
| 16 | height <= 0 || |
| 17 | x + width > 1.01 || |
| 18 | y + height > 1.01 |
| 19 | ) { |
| 20 | throw new Error("Invalid capture animation destination."); |
| 21 | } |
| 22 | return { |
| 23 | x: bounds.x + x * bounds.width, |
| 24 | y: bounds.y + y * bounds.height, |
| 25 | width: width * bounds.width, |
| 26 | height: height * bounds.height, |
| 27 | }; |
| 28 | } |