feat: snap launcher to stippled edge alignment guides

This commit is contained in:
2026-10-12 12:25:18 +02:00
parent 97420f51e1
commit dc7cf07204
4 changed files with 101 additions and 12 deletions
@@ -0,0 +1,20 @@
import Foundation
public struct LauncherAlignment: Sendable {
public let targetFrame: CGRect
public let snappedOrigin: CGPoint
public init(windowFrame: CGRect, visibleFrame: CGRect) {
// Whole-point origins keep the guides aligned with AppKit's window positioning.
targetFrame = CGRect(
x: (visibleFrame.midX - windowFrame.width / 2).rounded(.down),
y: (visibleFrame.midY - windowFrame.height / 2).rounded(.down),
width: windowFrame.width,
height: windowFrame.height
)
snappedOrigin = CGPoint(
x: abs(windowFrame.minX - targetFrame.minX) <= 12 ? targetFrame.minX : windowFrame.minX,
y: abs(windowFrame.maxY - targetFrame.maxY) <= 12 ? targetFrame.minY : windowFrame.minY
)
}
}