mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
Rename maximize notification and refine handler
This commit is contained in:
@@ -117,8 +117,8 @@ class BaseTerminalController: NSWindowController,
|
||||
object: nil)
|
||||
center.addObserver(
|
||||
self,
|
||||
selector: #selector(toggleMaximize),
|
||||
name: .ghosttyToggleMaximize,
|
||||
selector: #selector(ghosttyMaximizeDidToggle(_:)),
|
||||
name: .ghosttyMaximizeDidToggle,
|
||||
object: nil)
|
||||
|
||||
// Listen for local events that we need to know of outside of
|
||||
@@ -239,6 +239,13 @@ class BaseTerminalController: NSWindowController,
|
||||
toggleCommandPalette(nil)
|
||||
}
|
||||
|
||||
@objc private func ghosttyMaximizeDidToggle(_ notification: Notification) {
|
||||
guard let window else { return }
|
||||
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
|
||||
guard surfaceTree?.contains(view: surfaceView) ?? false else { return }
|
||||
window.zoom(nil)
|
||||
}
|
||||
|
||||
// MARK: Local Events
|
||||
|
||||
private func localEventHandler(_ event: NSEvent) -> NSEvent? {
|
||||
@@ -553,11 +560,6 @@ class BaseTerminalController: NSWindowController,
|
||||
window.performClose(sender)
|
||||
}
|
||||
|
||||
@IBAction func toggleMaximize(_ sender: Any) {
|
||||
guard let window = window else { return }
|
||||
window.zoom(self)
|
||||
}
|
||||
|
||||
@IBAction func splitRight(_ sender: Any) {
|
||||
guard let surface = focusedSurface?.surface else { return }
|
||||
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DIRECTION_RIGHT)
|
||||
|
@@ -783,7 +783,7 @@ extension Ghostty {
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
NotificationCenter.default.post(
|
||||
name: .ghosttyToggleMaximize,
|
||||
name: .ghosttyMaximizeDidToggle,
|
||||
object: surfaceView
|
||||
)
|
||||
|
||||
|
@@ -259,7 +259,7 @@ extension Notification.Name {
|
||||
static let ghosttyCommandPaletteDidToggle = Notification.Name("com.mitchellh.ghostty.commandPaletteDidToggle")
|
||||
|
||||
/// Toggle maximize of current window
|
||||
static let ghosttyToggleMaximize = Notification.Name("com.mitchellh.ghostty.toggleMaximize")
|
||||
static let ghosttyMaximizeDidToggle = Notification.Name("com.mitchellh.ghostty.maximizeDidToggle")
|
||||
}
|
||||
|
||||
// NOTE: I am moving all of these to Notification.Name extensions over time. This
|
||||
|
Reference in New Issue
Block a user