Persist complete monitor layouts

This commit is contained in:
Gabriel Brown
2026-08-18 15:00:18 -04:00
parent 2613768efd
commit d0d9e196b0
5 changed files with 139 additions and 12 deletions
+46 -7
View File
@@ -42,7 +42,10 @@ for contract in \
'readonly property bool canConfirm:' \
'function matchesRequest(' \
'function scalesForMode(' \
'function isScaleClean('; do
'function isScaleClean(' \
'x: Number.isInteger(monitor.x)' \
'y: Number.isInteger(monitor.y)' \
'primary: monitor.name === primaryName'; do
rg -Fq "$contract" "$service" || fail "display service contract is missing: $contract"
done
rg -Fq 'enabled: Displays.canConfirm' "$page" \
@@ -60,7 +63,7 @@ rg -Fq 'if (root.busy)' "$service" \
# 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.
for contract in 'valid_mode' 'valid_scale' 'valid_transform' 'pairs(displays)'; do
for contract in 'valid_mode' 'valid_scale' 'valid_transform' 'valid_position' 'valid_primary' 'pairs(displays)'; do
rg -Fq "$contract" "$monitors_lua" || fail "monitor startup validation is missing: $contract"
done
@@ -79,9 +82,27 @@ package.preload["prefs"] = function()
return {
get = function()
return {
["DP-2"] = { mode = "not-a-mode", scale = -1, transform = 99 },
["HDMI-A-1"] = { mode = "1920x1080@60", scale = 1.5, transform = 1 },
["BAD OUTPUT"] = { mode = "1920x1080@60", scale = 1, transform = 0 },
["DP-2"] = {
mode = "4500x3000@60", scale = 1.5, transform = 0,
x = 0, y = 0, primary = true,
},
["HDMI-A-1"] = {
mode = "2560x1440@60", scale = 1, transform = 1,
x = 3000, y = 0, primary = false,
},
["LEGACY-1"] = { mode = "1920x1080@60", scale = 1.5, transform = 0 },
["PARTIAL-1"] = {
mode = "1920x1080@60", scale = 1, transform = 0,
x = 4440,
},
["BAD-PRIMARY"] = {
mode = "1920x1080@60", scale = 1, transform = 0,
x = 4440, y = 0, primary = "yes",
},
["BAD OUTPUT"] = {
mode = "1920x1080@60", scale = 1, transform = 0,
x = 4440, y = 0, primary = false,
},
}
end,
}
@@ -96,13 +117,24 @@ for _, value in ipairs(calls) do by_output[value.output] = value end
assert(by_output["DP-2"].mode == "4500x3000@60")
assert(by_output["DP-2"].scale == 1.5)
assert(by_output["DP-2"].transform == 0)
assert(by_output["HDMI-A-1"].mode == "1920x1080@60")
assert(by_output["HDMI-A-1"].scale == 1.5)
assert(by_output["DP-2"].position == "0x0")
assert(by_output["DP-2"].bitdepth == 10)
assert(by_output["DP-2"].cm == "auto")
assert(by_output["HDMI-A-1"].mode == "2560x1440@60")
assert(by_output["HDMI-A-1"].scale == 1)
assert(by_output["HDMI-A-1"].transform == 1)
assert(by_output["HDMI-A-1"].position == "3000x0")
assert(by_output["LEGACY-1"].position == "auto")
assert(by_output["PARTIAL-1"] == nil)
assert(by_output["BAD-PRIMARY"] == nil)
assert(by_output["BAD OUTPUT"] == nil)
assert(by_output[""] ~= nil)
LUA
rg -Fq 'Resolution, scale, rotation, position, and primary display' \
"$repo_dir/config/dot/quickshell/config/PreferenceSchema.qml" \
|| fail 'the display preference does not document complete layout persistence'
if [[ "${PANAMA_DISPLAYS_STATIC_ONLY:-0}" == "1" ]]; then
printf 'displays contract: PASS (static)\n'
exit 0
@@ -209,6 +241,13 @@ jq -e '
' <<<"$refresh_fixture" >/dev/null \
|| fail "59.94 Hz and 60.00 Hz lost their distinct selection identity: $refresh_fixture"
position_fixture="$(run ipc call displays-test positionFixture)"
jq -e '. == [
{"name":"DP-2","x":140,"y":80,"primary":true},
{"name":"HDMI-A-1","x":3140,"y":80,"primary":false}
]' <<<"$position_fixture" >/dev/null \
|| fail "monitor positions or primary selection were parsed incorrectly: $position_fixture"
for _ in $(seq 1 50); do
[[ "$(status | jq -r .count)" != "0" ]] && break
sleep 0.1