mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 12:11:28 -07:00
fix(tracker): follow active hyprland and visible x11 windows
This commit is contained in:
@@ -18,11 +18,51 @@ Height: 720
|
||||
});
|
||||
});
|
||||
|
||||
test('parseX11WindowGeometry preserves negative coordinates', () => {
|
||||
const geometry = parseX11WindowGeometry(`
|
||||
Absolute upper-left X: -1920
|
||||
Absolute upper-left Y: -24
|
||||
Width: 1920
|
||||
Height: 1080
|
||||
`);
|
||||
assert.deepEqual(geometry, {
|
||||
x: -1920,
|
||||
y: -24,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
});
|
||||
});
|
||||
|
||||
test('parseX11WindowPid parses xprop output', () => {
|
||||
assert.equal(parseX11WindowPid('_NET_WM_PID(CARDINAL) = 4242'), 4242);
|
||||
assert.equal(parseX11WindowPid('_NET_WM_PID(CARDINAL) = not-a-number'), null);
|
||||
});
|
||||
|
||||
test('X11WindowTracker searches only visible mpv windows', async () => {
|
||||
const commands: Array<{ command: string; args: string[] }> = [];
|
||||
const tracker = new X11WindowTracker(undefined, async (command, args) => {
|
||||
commands.push({ command, args });
|
||||
if (command === 'xdotool') {
|
||||
return '123';
|
||||
}
|
||||
if (command === 'xwininfo') {
|
||||
return `Absolute upper-left X: 0
|
||||
Absolute upper-left Y: 0
|
||||
Width: 640
|
||||
Height: 360`;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
(tracker as unknown as { pollGeometry: () => void }).pollGeometry();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
assert.deepEqual(commands[0], {
|
||||
command: 'xdotool',
|
||||
args: ['search', '--onlyvisible', '--class', 'mpv'],
|
||||
});
|
||||
});
|
||||
|
||||
test('X11WindowTracker skips overlapping polls while one command is in flight', async () => {
|
||||
let commandCalls = 0;
|
||||
let release: (() => void) | undefined;
|
||||
|
||||
Reference in New Issue
Block a user