mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: set initial terminal dimensions
This commit is contained in:
@ -36,6 +36,9 @@ class SlideTerminalController: BaseTerminalController {
|
|||||||
// make this restorable, but it isn't currently implemented.
|
// make this restorable, but it isn't currently implemented.
|
||||||
window.isRestorable = false
|
window.isRestorable = false
|
||||||
|
|
||||||
|
// Setup our initial size based on our configured position
|
||||||
|
position.setLoaded(window)
|
||||||
|
|
||||||
// Setup our content
|
// Setup our content
|
||||||
window.contentView = NSHostingView(rootView: TerminalView(
|
window.contentView = NSHostingView(rootView: TerminalView(
|
||||||
ghostty: self.ghostty,
|
ghostty: self.ghostty,
|
||||||
|
@ -3,6 +3,20 @@ import Cocoa
|
|||||||
enum SlideTerminalPosition {
|
enum SlideTerminalPosition {
|
||||||
case top
|
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.
|
/// Set the initial state for a window for animating out of this position.
|
||||||
func setInitial(in window: NSWindow, on screen: NSScreen) {
|
func setInitial(in window: NSWindow, on screen: NSScreen) {
|
||||||
// We always start invisible
|
// We always start invisible
|
||||||
|
@ -23,6 +23,9 @@ class SlideTerminalWindow: NSWindow {
|
|||||||
// and lets us render off screen.
|
// and lets us render off screen.
|
||||||
self.level = .popUpMenu
|
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 = [
|
self.collectionBehavior = [
|
||||||
// We want this to be part of every space because it is a singleton.
|
// We want this to be part of every space because it is a singleton.
|
||||||
.canJoinAllSpaces,
|
.canJoinAllSpaces,
|
||||||
|
Reference in New Issue
Block a user