diff --git a/tools/re-capture/bin/screenshot b/tools/re-capture/bin/screenshot index c1eeb1bb..abccb1dc 100755 --- a/tools/re-capture/bin/screenshot +++ b/tools/re-capture/bin/screenshot @@ -25,9 +25,26 @@ RAW="$(mktemp /tmp/shot-raw-XXXXXX.png)" trap 'rm -f "$RAW"' EXIT "$REAL" "$RAW" >/dev/null || exit 1 -# "…": ("xenia_canary" "Xenia_canary") 1280x745+0+0 +0+0 -geo=$(xwininfo -root -children 2>/dev/null \ - | grep '"xenia_canary"' | grep -oE '[0-9]+x[0-9]+\+-?[0-9]+\+-?[0-9]+' | head -1) +# "…": ("xenia_canary" "Xenia_canary") 1280x745+1+20 +1+45 +# +# TWO traps here, both measured (2026-08-18): +# * `-children` only lists DIRECT children of the root, and openbox reparents +# the game window, so the real one is not there at all; +# * this app owns more than one window with the class "xenia_canary" — an +# off-screen 10x10 helper as well as the 1280x745 game window — so `head -1` +# picked the 10x10 one and every grab came back a 10-pixel sliver. Nothing +# errored: the pixel oracles simply classified the sliver, and a whole +# session's screen ids were noise. +# So walk the full tree and take the LARGEST xenia window, by area. Use the +# trailing ABSOLUTE geometry (the second +X+Y), because a reparented window's +# own +X+Y is relative to its frame. +geo=$(xwininfo -root -tree 2>/dev/null \ + | grep '"xenia_canary"' \ + | grep -oE '[0-9]+x[0-9]+\+-?[0-9]+\+-?[0-9]+[[:space:]]+\+-?[0-9]+\+-?[0-9]+' \ + | awk '{ split($1, g, /[x+]/); a = g[1] * g[2]; + if (a > best) { best = a; split($2, p, /\+/); + out = g[1] "x" g[2] "+" p[2] "+" p[3] } } + END { if (best) print out }') if [ -z "$geo" ]; then # no window found — hand back the raw grab cp "$RAW" "$OUT"; echo "$OUT"; exit 0 fi