21 lines
829 B
Swift
21 lines
829 B
Swift
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.maxY - visibleFrame.height / 5 - windowFrame.height).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
|
|
)
|
|
}
|
|
}
|