// The still window the fan's painter waits for (`PagePainter`, architect, 14// Oct 2026): nothing is drawn off screen until the window has been quiet, and// once a finger has gone down nothing more is drawn until it is quiet again.importSwiftUI#if os(iOS)import UIKit#endifenumStillWindow {/// How long the window must have been still before anything is drawn/// off screen.staticlet quiet: Duration = .milliseconds(300)}#if os(iOS)/// Whether a finger has gone down in the key window since it was installed: a/// recognizer that never recognizes, never delays a touch and never cancels/// one, so every control under it behaves exactly as without it.@MainActorfinalclassTouchWatch: UIGestureRecognizer, UIGestureRecognizerDelegate {private(set) var touched = false/// Called as a finger lands, so work waiting on the still window stops at once.var onTouch: (() -> Void)?staticfunc install() -> TouchWatch? {let window = UIApplication.shared.connectedScenes .compactMap { $0 as? UIWindowScene } .flatMap(\.windows) .first(where: \.isKeyWindow)guardlet window else { returnnil }let watch = TouchWatch(target: nil, action: nil) watch.cancelsTouchesInView = false watch.delaysTouchesBegan = false watch.delaysTouchesEnded = false watch.delegate = watch window.addGestureRecognizer(watch)return watch }func remove() { view?.removeGestureRecognizer(self) }overridefunc touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { touched = true onTouch?() state = .failed }func gestureRecognizer(_ recognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith other: UIGestureRecognizer) -> Bool {true }}#endif