From 794420810ca8ff00483af5808a22ec69e0d8e276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 1 Aug 2026 20:31:06 +0000 Subject: [PATCH] vnc: count enabled outputs, not connected ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/servers/sidecar/vnc/vnc-manager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/servers/sidecar/vnc/vnc-manager.ts b/src/servers/sidecar/vnc/vnc-manager.ts index 9eb9cdaf..372d93a3 100644 --- a/src/servers/sidecar/vnc/vnc-manager.ts +++ b/src/servers/sidecar/vnc/vnc-manager.ts @@ -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.