Refactor to use height/width from ghostty configuration

This commit is contained in:
Mikhail Borisov
2025-02-25 21:47:33 +01:00
committed by Mitchell Hashimoto
parent f73c1a2c59
commit 8838ebf02a
3 changed files with 61 additions and 35 deletions

View File

@@ -753,16 +753,6 @@ class AppDelegate: NSObject,
quickController.toggle()
}
@IBAction func returnToDefaultSize(_ sender: Any) {
guard let window = NSApp.keyWindow else { return }
let currentOrigin = window.frame.origin
let newFrame = NSRect(
origin: currentOrigin,
size: WindowConfig.defaultSize
)
window.setFrame(newFrame, display: true)
}
/// Toggles visibility of all Ghosty Terminal windows. When hidden, activates Ghostty as the frontmost application
@IBAction func toggleVisibility(_ sender: Any) {
// If we have focus, then we hide all windows.
@@ -814,10 +804,6 @@ class AppDelegate: NSObject,
}
}
private enum WindowConfig {
static let defaultSize = CGSize(width: 800, height: 600)
}
private struct ToggleVisibilityState {
let hiddenWindows: [Weak<NSWindow>]
let keyWindow: Weak<NSWindow>?
@@ -847,23 +833,3 @@ class AppDelegate: NSObject,
}
}
}
extension AppDelegate: NSMenuItemValidation {
func validateMenuItem(_ item: NSMenuItem) -> Bool {
switch item.action {
case #selector(returnToDefaultSize):
guard let focusedWindow = NSApp.keyWindow else {
return false
}
if focusedWindow.styleMask.contains(.fullScreen) {
return false
}
if focusedWindow.frame.size == WindowConfig.defaultSize {
return false
}
return true
default:
return true
}
}
}