vnc: count enabled outputs, not connected ones

A screen that is plugged in but switched off still reports "connected" to xrandr while contributing
nothing to the framebuffer — which is exactly the state this machine is now in, with the unused KVM
output disabled. Counting those made the mirror take the multi-output path and clip to the primary
when there was only one live screen; harmless here because the clip equalled the whole framebuffer,
but wrong, and it would have masked a real single-screen case.

Only an enabled output carries a WxH+X+Y geometry, so requiring that in the pattern is what tells
the two apart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-01 20:31:06 +00:00
co-authored by Claude Opus 5
parent 2ddefa000c
commit 794420810c
+4 -1
View File
@@ -140,7 +140,10 @@ function readDisplayGeometry(xauthority: string, display: string): DisplayGeomet
const out = proc.stdout.toString();
const fb = out.match(/current\s+(\d+)\s*x\s*(\d+)/);
const connected = (out.match(/^\S+ connected/gm) ?? []).length;
// Count ENABLED outputs, not merely connected ones: a screen that is plugged in but switched off
// still reports "connected" and contributes nothing to the framebuffer. Only an enabled output
// carries a WxH+X+Y geometry, so requiring that is what distinguishes the two.
const connected = (out.match(/^\S+ connected(?: primary)? \d+x\d+\+\d+\+\d+/gm) ?? []).length;
// "HDMI-A-0 connected primary 3840x2160+0+0 (normal left ..." — the geometry only appears on an
// output that is actually enabled, so a connected-but-off output correctly yields no match.