Verify display restoration and expose outputs

This commit is contained in:
Gabriel Brown
2026-08-18 02:55:43 -04:00
parent 67674d297e
commit efc53435a2
4 changed files with 124 additions and 30 deletions
+11 -2
View File
@@ -36,6 +36,7 @@ fail() {
# Keep is unavailable until compositor readback exactly matches the request.
for contract in \
'property var pendingRequested:' \
'property var revertExpected:' \
'readonly property bool canConfirm:' \
'function matchesRequest(' \
'function scalesForMode(' \
@@ -46,6 +47,14 @@ rg -Fq 'enabled: Displays.canConfirm' "$page" \
|| fail 'Keep is enabled before the display change is verified'
rg -Fq 'options: Displays.scalesForMode(' "$page" \
|| fail 'scale choices are not filtered for the active resolution'
rg -Fq 'property string selectedOutput:' "$page" \
|| fail 'connected outputs cannot be selected'
rg -Fq 'options: Displays.monitors.map(' "$page" \
|| fail 'the output selector is not populated from connected displays'
rg -Fq 'id: revertVerifyTimer' "$service" \
|| fail 'automatic restoration has no bounded readback verification'
rg -Fq 'if (root.busy)' "$service" \
|| fail 'the display service accepts a new apply while another operation is busy'
# Stored JSON is untyped at field level, so the Lua startup consumer is the
# final validation boundary and must support every named output it accepts.
@@ -125,7 +134,7 @@ display_is_restored() {
--argjson scale "$original_scale" \
--argjson transform "$original_transform" \
'.width == $width and .height == $height
and ((.refreshRate - $refresh) | fabs) < 0.6
and ((.refreshRate - $refresh) | fabs) < 0.01
and ((.scale - $scale) | fabs) < 0.001
and .transform == $transform' <<<"$current" >/dev/null
}
@@ -179,7 +188,7 @@ done
state="$(status)"
monitor_name="$(jq -r .name <<<"$state")"
[[ -n "$monitor_name" ]] || fail "no display was detected: $state"
original_mode="$(jq -r '"\(.width)x\(.height)@\(.refresh)"' <<<"$state")"
original_mode="$(jq -r .mode <<<"$state")"
original_width="$(jq -r .width <<<"$state")"
original_height="$(jq -r .height <<<"$state")"
original_refresh="$(jq -r .refresh <<<"$state")"