feat: load optional XDG TOML configuration with session overrides

This commit is contained in:
2026-10-11 14:41:11 +02:00
parent 0dce073287
commit 722a225da5
16 changed files with 461 additions and 89 deletions
+7 -12
View File
@@ -93,7 +93,7 @@ struct CompactWindowChecks {
"target width shrinks to usable bounds without distorting ordinary aspect")
}
static func windowBehavior(defaults: UserDefaults) throws {
static func windowBehavior() throws {
_ = NSApplication.shared
guard let screen = NSScreen.main else {
throw Failure(description: "FAIL: native window checks require a macOS GUI session with a screen")
@@ -127,7 +127,7 @@ struct CompactWindowChecks {
let originalHides = window.hidesOnDeactivate
let originalDrag = window.isMovableByWindowBackground
let identity = ObjectIdentifier(window)
let controller = CompactWindowController(defaults: defaults)
let controller = CompactWindowController()
defer { controller.restore(resumeFullScreen: false) }
controller.attach(window)
try require(!controller.isCompact && !controller.isTransitioning, "attached window starts ordinary")
@@ -182,14 +182,14 @@ struct CompactWindowChecks {
try require(close(window.frame.minX, visible.minX + 16) && close(window.frame.minY, visible.minY + 16)
&& window.frame.size == nearEdge.size, "enabled preference snaps the actual moved window")
controller.snappingEnabled = false
let second = CompactWindowController(defaults: defaults)
try require(!second.snappingEnabled, "disabled preference persists across controller instances")
let second = CompactWindowController(snappingEnabled: false)
try require(!second.snappingEnabled, "configuration can disable snapping for a new controller")
window.setFrame(nearEdge, display: false)
controller.snapAfterDrag()
try require(sameFrame(window.frame, nearEdge), "disabled preference leaves an actual moved window untouched")
second.snappingEnabled = true
let third = CompactWindowController(defaults: defaults)
try require(third.snappingEnabled, "re-enabled preference persists across controller instances")
let third = CompactWindowController(snappingEnabled: false)
try require(!third.snappingEnabled, "a session override does not change the next controller's settings")
controller.snappingEnabled = true
let resized = NSRect(x: nearEdge.minX, y: nearEdge.minY, width: 240, height: 135)
window.setFrame(resized, display: false)
@@ -218,13 +218,8 @@ struct CompactWindowChecks {
}
static func main() throws {
let suite = "terebi.compact-window-checks.\(UUID().uuidString)"
guard let defaults = UserDefaults(suiteName: suite) else {
throw Failure(description: "FAIL: cannot create isolated preference suite")
}
defer { defaults.removePersistentDomain(forName: suite) }
try geometry()
try windowBehavior(defaults: defaults)
try windowBehavior()
print("Compact window checks passed")
}
}