mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-10 12:21:16 +02:00
Co-authored-by: Dara Adedeji <daraadedeji07@gmail.com> Co-authored-by: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Co-authored-by: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
28 lines
908 B
JavaScript
28 lines
908 B
JavaScript
// PID comes from the bus daemon, not from the caller. Never focus a different T3 process.
|
|
export function findCaptureDestination(windows, pid, title) {
|
|
const owned = windows.filter((window) => window.get_pid() === pid);
|
|
const matching = owned.filter((window) => window.get_title() === title);
|
|
if (matching.length === 1) return matching[0];
|
|
return owned.length === 1 ? owned[0] : undefined;
|
|
}
|
|
|
|
export function captureDestinationFrame(relative, bounds) {
|
|
const { x, y, width, height } = relative;
|
|
if (
|
|
![x, y, width, height].every(Number.isFinite) ||
|
|
x < 0 ||
|
|
y < 0 ||
|
|
width <= 0 ||
|
|
height <= 0 ||
|
|
x + width > 1.01 ||
|
|
y + height > 1.01
|
|
) {
|
|
throw new Error("Invalid capture animation destination.");
|
|
}
|
|
return {
|
|
x: bounds.x + x * bounds.width,
|
|
y: bounds.y + y * bounds.height,
|
|
width: width * bounds.width,
|
|
height: height * bounds.height,
|
|
};
|
|
}
|