Files
Panama/tests/quickshell/per-screen-surface-contract.sh
T
Gabriel Brown 1360a80f07 Add a visible window switcher
Super+Tab already cycled windows, but nothing was drawn, so you chose
blind and could only confirm the choice by arriving. A visible switcher
is muscle memory for anyone arriving from macOS or GNOME, and it was the
last item of roadmap phase 03 that did not need coordination.

Ordered most-recently-used, not by creation, because that is what makes
the gesture useful: one Tab returns to the window you just came from.
Hyprland does not report an MRU order, so it is tracked from focus
changes and keyed by address, which is the only property stable for a
window's lifetime.

The gesture needs three binds rather than two. Tab steps the selection,
and the switch is committed on Super RELEASE -- the only way the
compositor can say the gesture is over. That bind is on the bare
modifier, so it fires on every Super release in the session; commit()
returns immediately when nothing is open, which is what makes it
affordable.

A list of names rather than thumbnails: at a glance you are looking for
"the other terminal", and a row of live previews is slower to read and
far more expensive to draw than this gesture deserves.

The interesting part is the bug. The overlay was built, mapped nothing,
and logged absolutely nothing -- because it declared `required property
var screen` while Variants supplies `modelData`. shell.qml has carried a
comment warning about exactly this since the Bar hit it, and I read that
comment earlier in the same session and still walked into it. A comment
that does not stop the person who read it is an argument for a test, so
per-screen-surface-contract now checks every per-screen delegate takes
its screen from modelData. Verified it catches the exact mistake.

Also fixes a regression from 8be3fc2: settings-pages-contract still
required vitalsIntervalMs on Home, where it no longer is. That contract
was pinning the split-across-two-pages arrangement the same commit
fixed, and I pushed without running it.

Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
2026-08-18 14:56:15 -04:00

61 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Anything instantiated per screen must take its screen from `modelData`.
#
# Variants supplies each delegate a `modelData` holding the screen. A component
# that instead declares `required property var screen` is constructed, never
# receives a screen, and its window silently never maps -- with nothing logged,
# no error, and no visible failure beyond the surface simply not being there.
#
# shell.qml has warned about this in a comment since the Bar hit it. The comment
# did not stop the window switcher hitting it again, which is the argument for a
# test: the failure is invisible, so review does not catch it either.
set -uo pipefail
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
shell_file="$repo_dir/config/dot/quickshell/shell.qml"
modules="$repo_dir/config/dot/quickshell/modules"
fail() {
printf 'per-screen surface contract: %s\n' "$1" >&2
exit 1
}
[[ -r "$shell_file" ]] || fail "cannot read shell.qml"
# The component named inside each `Variants { model: Quickshell.screens ... }`.
delegates="$(awk '
/Variants \{/ { inside = 1; next }
inside && /model: Quickshell.screens/ { armed = 1; next }
armed && /^[[:space:]]*[A-Z][A-Za-z]* *\{/ {
match($0, /[A-Z][A-Za-z]*/)
print substr($0, RSTART, RLENGTH)
armed = 0; inside = 0
}
' "$shell_file" | sort -u)"
[[ -n "$delegates" ]] || fail 'found no per-screen delegates -- this contract is not reading shell.qml correctly'
checked=0
while read -r name; do
[[ -n "$name" ]] || continue
file="$(find "$modules" -name "$name.qml" -print -quit 2>/dev/null)"
[[ -n "$file" ]] || fail "shell.qml instantiates $name per screen, but $name.qml was not found"
if grep -qE '^\s*required property var screen\b' "$file"; then
fail "$name declares 'required property var screen', but Variants supplies modelData -- the window is built and never maps, silently. Use 'property var modelData' and bind screen to it, as Bar and Dock do."
fi
grep -qE '^\s*property var modelData' "$file" \
|| fail "$name is instantiated per screen but never declares 'property var modelData', so it cannot know which screen it is on"
grep -qE 'screen: (root\.)?modelData' "$file" \
|| fail "$name declares modelData but never binds a screen to it"
checked=$((checked + 1))
done <<<"$delegates"
printf 'per-screen surface contract: PASS (%d per-screen surfaces)\n' "$checked"