From 982d1bc27dc87d1913f5d8341c35c9da2e0e1acf Mon Sep 17 00:00:00 2001 From: Friedrich Stoltzfus Date: Thu, 26 Jun 2025 10:51:36 -0400 Subject: [PATCH] macOS: Round quick terminal window position coordinates This resolves an issue where the right side of the quick terminal would not resize equally to the left side if adjusting the width from the left side. --- .../QuickTerminal/QuickTerminalPosition.swift | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift index bf7ed4b08..418d8da94 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift @@ -58,19 +58,19 @@ enum QuickTerminalPosition : String { func initialOrigin(for window: NSWindow, on screen: NSScreen) -> CGPoint { switch (self) { case .top: - return .init(x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, y: screen.frame.maxY) + return .init(x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: screen.frame.maxY) case .bottom: - return .init(x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, y: -window.frame.height) + return .init(x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: -window.frame.height) case .left: - return .init(x: screen.frame.minX-window.frame.width, y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) + return .init(x: screen.frame.minX-window.frame.width, y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2)) case .right: - return .init(x: screen.frame.maxX, y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) + return .init(x: screen.frame.maxX, y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2)) case .center: - return .init(x: screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2, y: screen.visibleFrame.height - window.frame.width) + return .init(x: round(screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2), y: screen.visibleFrame.height - window.frame.width) } } @@ -78,19 +78,19 @@ enum QuickTerminalPosition : String { func finalOrigin(for window: NSWindow, on screen: NSScreen) -> CGPoint { switch (self) { case .top: - return .init(x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, y: screen.visibleFrame.maxY - window.frame.height) + return .init(x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: screen.visibleFrame.maxY - window.frame.height) case .bottom: - return .init(x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, y: screen.frame.minY) + return .init(x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: screen.frame.minY) case .left: - return .init(x: screen.frame.minX, y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) + return .init(x: screen.frame.minX, y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2)) case .right: - return .init(x: screen.visibleFrame.maxX - window.frame.width, y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) + return .init(x: screen.visibleFrame.maxX - window.frame.width, y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2)) case .center: - return .init(x: screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2, y: screen.visibleFrame.origin.y + (screen.visibleFrame.height - window.frame.height) / 2) + return .init(x: round(screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2), y: round(screen.visibleFrame.origin.y + (screen.visibleFrame.height - window.frame.height) / 2)) } } @@ -117,20 +117,20 @@ enum QuickTerminalPosition : String { switch self { case .top: return CGPoint( - x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, + x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: window.frame.origin.y // Keep the same Y position ) case .bottom: return CGPoint( - x: screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2, + x: round(screen.frame.origin.x + (screen.frame.width - window.frame.width) / 2), y: window.frame.origin.y // Keep the same Y position ) case .center: return CGPoint( - x: screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2, - y: screen.visibleFrame.origin.y + (screen.visibleFrame.height - window.frame.height) / 2 + x: round(screen.visibleFrame.origin.x + (screen.visibleFrame.width - window.frame.width) / 2), + y: round(screen.visibleFrame.origin.y + (screen.visibleFrame.height - window.frame.height) / 2) ) case .left, .right: @@ -145,13 +145,13 @@ enum QuickTerminalPosition : String { case .left: return CGPoint( x: window.frame.origin.x, // Keep the same X position - y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2 + y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) ) case .right: return CGPoint( x: window.frame.origin.x, // Keep the same X position - y: screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2 + y: round(screen.frame.origin.y + (screen.frame.height - window.frame.height) / 2) ) case .top, .bottom, .center: