mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: restrict resizing based on sliding terminal position
This commit is contained in:
@ -10,7 +10,7 @@ class SlideTerminalController: NSWindowController, NSWindowDelegate, TerminalVie
|
|||||||
/// The app instance that this terminal view will represent.
|
/// The app instance that this terminal view will represent.
|
||||||
let ghostty: Ghostty.App
|
let ghostty: Ghostty.App
|
||||||
|
|
||||||
/// The position fo the slide terminal.
|
/// The position for the slide terminal.
|
||||||
let position: SlideTerminalPosition
|
let position: SlideTerminalPosition
|
||||||
|
|
||||||
/// The surface tree for this window.
|
/// The surface tree for this window.
|
||||||
@ -65,6 +65,11 @@ class SlideTerminalController: NSWindowController, NSWindowDelegate, TerminalVie
|
|||||||
slideOut()
|
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
|
//MARK: TerminalViewDelegate
|
||||||
|
|
||||||
func cellSizeDidChange(to: NSSize) {
|
func cellSizeDidChange(to: NSSize) {
|
||||||
|
@ -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.
|
/// The initial point origin for this position.
|
||||||
func initialOrigin(for window: NSWindow, on screen: NSScreen) -> CGPoint {
|
func initialOrigin(for window: NSWindow, on screen: NSScreen) -> CGPoint {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
|
Reference in New Issue
Block a user