macos: set initial terminal dimensions

This commit is contained in:
Mitchell Hashimoto
2024-09-28 15:08:14 -07:00
parent 1977e220f5
commit e3b340c6d3
3 changed files with 20 additions and 0 deletions

View File

@ -36,6 +36,9 @@ class SlideTerminalController: BaseTerminalController {
// make this restorable, but it isn't currently implemented.
window.isRestorable = false
// Setup our initial size based on our configured position
position.setLoaded(window)
// Setup our content
window.contentView = NSHostingView(rootView: TerminalView(
ghostty: self.ghostty,

View File

@ -3,6 +3,20 @@ import Cocoa
enum SlideTerminalPosition {
case top
/// Set the loaded state for a window.
func setLoaded(_ window: NSWindow) {
guard let screen = window.screen ?? NSScreen.main else { return }
switch (self) {
case .top:
window.setFrame(.init(
origin: window.frame.origin,
size: .init(
width: screen.frame.width,
height: screen.frame.height / 4)
), display: false)
}
}
/// Set the initial state for a window for animating out of this position.
func setInitial(in window: NSWindow, on screen: NSScreen) {
// We always start invisible

View File

@ -23,6 +23,9 @@ class SlideTerminalWindow: NSWindow {
// and lets us render off screen.
self.level = .popUpMenu
// This plus the level above was what was needed for the animation to work,
// because it gets the window off screen properly. Plus we add some fields
// we just want the behavior of.
self.collectionBehavior = [
// We want this to be part of every space because it is a singleton.
.canJoinAllSpaces,