AtlatestRepositorysigil-wm
1
#!/usr/bin/env bash2
set -euo pipefail3
cd "$(dirname "$0")/.."4
make -j2 all build/protocol-client5
mkdir -p build/receipts6
runtime_dir=$(mktemp -d /tmp/sigil-wm-decorations.XXXXXX)7
export XDG_RUNTIME_DIR="$runtime_dir" SIGIL_WM_REPL="$runtime_dir/repl"8
export WLR_BACKENDS=headless WLR_RENDERER=pixman WLR_HEADLESS_OUTPUTS=19
unset WAYLAND_DISPLAY DISPLAY10
server_pid= client_pid=11
cleanup() {12
for child in "$client_pid" "$server_pid"; do13
[[ -z $child ]] || kill "$child" 2>/dev/null || true14
[[ -z $child ]] || wait "$child" 2>/dev/null || true15
done16
rm -rf "$runtime_dir"17
}18
trap cleanup EXIT19
value() { bash scripts/msg "$SIGIL_WM_REPL" "$1"; }20
wait_value() {21
for ((attempt=0; attempt<100; attempt++)); do22
if value "$1" | grep -q '(value #t)'; then return; fi23
sleep 0.0524
done25
cat build/receipts/decorations.log >&226
printf 'WAIT_FAILED=%s\n' "$1" >&227
return 128
}29
wait_count() {30
local count31
for ((attempt=0; attempt<200; attempt++)); do32
count=$(grep -c "$2" "$1" 2>/dev/null || true)33
if (( ${count:-0} >= $3 )); then return; fi34
sleep 0.0535
done36
tail -20 "$1" >&237
return 138
}39
timeout 180 bash scripts/run-sigil -L src eval -f test/decorations.sgl > build/receipts/decorations.log 2>&1 &40
server_pid=$!41
wait_count build/receipts/decorations.log '^WAYLAND_SOCKET=' 142
export WAYLAND_DISPLAY43
WAYLAND_DISPLAY=$(sed -n 's/^WAYLAND_SOCKET=//p' build/receipts/decorations.log | head -1)44
mkfifo "$runtime_dir/client-control"45
exec {client_control}<> "$runtime_dir/client-control"46
for variant in legacy-server legacy-client xdg; do47
value '(begin (set! before-role #f) (set! unselected? #f))'48
client_log="build/receipts/decoration-$variant.log"49
SIGIL_WM_CLIENT_DECORATION="$variant" timeout 60 build/protocol-client green 36000 < "$runtime_dir/client-control" > "$client_log" 2>&1 &50
client_pid=$!51
wait_value '(and (= (length windows) 1) (= (length (dict-ref (host-snapshot host) decorations:)) 1) (> (dict-ref (car (dict-ref (host-snapshot host) decorations:)) window:) 0))'52
if [[ $variant == legacy-* ]]; then53
wait_count "$client_log" '^LEGACY_DEFAULT=2' 154
wait_value '(and before-role (= (dict-ref (car (dict-ref before-role decorations:)) window:) 0) (eq? (dict-ref (car (dict-ref before-role decorations:)) mode:) (quote server)))'55
if [[ $variant == legacy-client ]]; then56
wait_value '(eq? (dict-ref (car (dict-ref (host-snapshot host) decorations:)) mode:) (quote client))'57
else58
wait_value '(eq? (dict-ref (car (dict-ref (host-snapshot host) decorations:)) mode:) (quote server))'59
fi60
printf 'd\n' >&"$client_control"61
wait_value '(eq? (dict-ref (car (dict-ref (host-snapshot host) decorations:)) mode:) (quote client))'62
printf 's\n' >&"$client_control"63
wait_value '(eq? (dict-ref (car (dict-ref (host-snapshot host) decorations:)) mode:) (quote server))'64
wait_value '(and (= (dict-ref (car (dict-ref before-role decorations:)) window:) 0) (eq? (dict-ref (car (dict-ref before-role decorations:)) mode:) (quote server)))'65
else66
wait_count "$client_log" '^XDG_DECORATION_MODE=2' 167
wait_value '(and unselected? (eq? (dict-ref (car (dict-ref (host-snapshot host) decorations:)) mode:) (quote server)))'68
fi69
sleep 0.370
value '(define states-before states)'71
serials=$(grep -c '^CLIENT_CONFIGURE_SERIAL=' "$client_log")72
printf 'f\n' >&"$client_control"73
wait_count "$client_log" '^CLIENT_FRAMES=' 174
frames_before=$(sed -n 's/^CLIENT_FRAMES=//p' "$client_log" | tail -1)75
sleep 0.776
printf 'f\n' >&"$client_control"77
wait_count "$client_log" '^CLIENT_FRAMES=' 278
frames_after=$(sed -n 's/^CLIENT_FRAMES=//p' "$client_log" | tail -1)79
(( frames_after >= frames_before+10 ))80
[[ $(grep -c '^CLIENT_CONFIGURE_SERIAL=' "$client_log") == "$serials" ]]81
wait_value '(= states states-before)'82
printf 'e\n' >&"$client_control"83
wait_value '(and (null? (dict-ref (host-snapshot host) decorations:)) (= (length windows) 1))'84
printf 'q\n' >&"$client_control"85
wait "$client_pid"86
client_pid=87
wait_value '(and (null? windows) (= (host-statistic host 1) 0))'88
printf 'DECORATION=PASS variant=%s pre-role copied association mode retirement quiet frames\n' "$variant"89
done90
value '(stop-host! host)'91
wait "$server_pid"92
server_pid=93
grep -q '^DECORATION_HOST=PASS' build/receipts/decorations.log94
echo 'DECORATIONS=PASS legacy defaults mode changes xdg explicit choice immutable snapshots no configure feedback ownership'