macos: restrict resizing based on sliding terminal position

This commit is contained in:
Mitchell Hashimoto
2024-09-22 21:35:07 -07:00
parent 63456d28a5
commit d18e1c879b
2 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@ class SlideTerminalController: NSWindowController, NSWindowDelegate, TerminalVie
/// The app instance that this terminal view will represent.
let ghostty: Ghostty.App
/// The position fo the slide terminal.
/// The position for the slide terminal.
let position: SlideTerminalPosition
/// The surface tree for this window.
@ -65,6 +65,11 @@ class SlideTerminalController: NSWindowController, NSWindowDelegate, TerminalVie
slideOut()
}
func windowWillResize(_ sender: NSWindow, to frameSize: NSSize) -> NSSize {
guard let screen = NSScreen.main else { return frameSize }
return position.restrictFrameSize(frameSize, on: screen)
}
//MARK: TerminalViewDelegate
func cellSizeDidChange(to: NSSize) {

View File

@ -35,6 +35,17 @@ enum SlideTerminalPosition {
}
}
/// Restrict the frame size during resizing.
func restrictFrameSize(_ size: NSSize, on screen: NSScreen) -> NSSize {
var finalSize = size
switch (self) {
case .top:
finalSize.width = screen.frame.width
}
return finalSize
}
/// The initial point origin for this position.
func initialOrigin(for window: NSWindow, on screen: NSScreen) -> CGPoint {
switch (self) {