mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-03 16:36:32 +00:00
macos: window-position-x/y are from top-left corner
Fixes #8672 Almost fully written by AI: https://ampcode.com/threads/T-86df68a3-578c-4a1c-91f3-788f8b8f0aae I reviewed all the code.
This commit is contained in:
@@ -41,4 +41,20 @@ extension NSScreen {
|
||||
// know any other situation this is true.
|
||||
return safeAreaInsets.top > 0
|
||||
}
|
||||
|
||||
/// Converts top-left offset coordinates to bottom-left origin coordinates for window positioning.
|
||||
/// - Parameters:
|
||||
/// - x: X offset from top-left corner
|
||||
/// - y: Y offset from top-left corner
|
||||
/// - windowSize: Size of the window to be positioned
|
||||
/// - Returns: CGPoint suitable for setFrameOrigin that positions the window as requested
|
||||
func origin(fromTopLeftOffsetX x: CGFloat, offsetY y: CGFloat, windowSize: CGSize) -> CGPoint {
|
||||
let vf = visibleFrame
|
||||
|
||||
// Convert top-left coordinates to bottom-left origin
|
||||
let originX = vf.minX + x
|
||||
let originY = vf.maxY - y - windowSize.height
|
||||
|
||||
return CGPoint(x: originX, y: originY)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user