tools: screenshot was grabbing a 10-pixel sliver, silently
The wrapper takes the xenia window's geometry from `xwininfo -root -children` and crops the game surface out of it. Two things are wrong with that here, and neither errors: * `-children` lists only DIRECT children of the root, and openbox reparents the game window — so the real one is not in that list at all; * the app owns more than one window of class "xenia_canary" — an off-screen 10x10 helper as well as the 1280x745 game window — so `head -1` picked the 10x10 one. Every grab came back a 10-pixel sliver, and nothing failed: `screen_id.py` happily classified the sliver, the movie-skip heuristic fired on its noise, and a whole session's worth of screen ids were meaningless. It also drove a stray tap into the title screen's save-data probe, which crashed the guest. Walk the full tree and take the largest xenia window by area, using its absolute geometry (a reparented window's own +X+Y is relative to its frame).
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user