feat: remember launcher position across restarts

This commit is contained in:
2026-10-12 14:24:14 +02:00
parent 0da8b8e241
commit 8d8e2278ab
4 changed files with 66 additions and 1 deletions
@@ -46,3 +46,19 @@ func launcherAlignmentKeepsFractionalDisplayCentersOnAStableWindowGrid() {
let placed = CGRect(origin: alignment.snappedOrigin, size: window.size)
#expect(LauncherAlignment(windowFrame: placed, visibleFrame: display).snappedOrigin == placed.origin)
}
@Test
func launcherPositionRestoresVisibleOriginsAndFallsBackForMissingOrOffscreenPositions() {
let display = CGRect(x: -1920, y: 40, width: 1920, height: 1040)
let size = CGSize(width: 750, height: 474)
let origin = CGPoint(x: -1500, y: 450)
#expect(LauncherAlignment.restoredFrame(savedOrigin: origin, windowSize: size, visibleFrame: display)
== CGRect(origin: origin, size: size))
for invalid: CGPoint? in [nil, CGPoint(x: 0, y: 450), CGPoint(x: -1500, y: 39), CGPoint(x: CGFloat.nan, y: 450)] {
#expect(LauncherAlignment.restoredFrame(savedOrigin: invalid, windowSize: size, visibleFrame: display)
== CGRect(x: -1335, y: 398, width: 750, height: 474))
}
let small = CGRect(x: 0, y: 40, width: 800, height: 500)
#expect(LauncherAlignment.restoredFrame(savedOrigin: nil, windowSize: size, visibleFrame: small)
== CGRect(x: 25, y: 40, width: 750, height: 474))
}