Merge pull request #1023 from mitchellh/macos-fs

macos: manually show window to handle mission control behavior
This commit is contained in:
Mitchell Hashimoto
2023-12-08 07:36:55 -08:00
committed by GitHub
2 changed files with 20 additions and 6 deletions

View File

@ -13,7 +13,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="👻 Ghostty" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="TerminalWindow" customModule="Ghostty" customModuleProvider="target"> <window title="👻 Ghostty" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="TerminalWindow" customModule="Ghostty" customModuleProvider="target">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="0.0" y="0.0" width="800" height="600"/> <rect key="contentRect" x="0.0" y="0.0" width="800" height="600"/>

View File

@ -63,16 +63,30 @@ class TerminalManager {
/// Create a new terminal window. /// Create a new terminal window.
func newWindow(withBaseConfig base: Ghostty.SurfaceConfiguration? = nil) { func newWindow(withBaseConfig base: Ghostty.SurfaceConfiguration? = nil) {
let c = createWindow(withBaseConfig: base) let c = createWindow(withBaseConfig: base)
if let window = c.window { let window = c.window!
Self.lastCascadePoint = window.cascadeTopLeft(from: Self.lastCascadePoint)
// We want to go fullscreen if we're configured for new windows to go fullscreen
var toggleFullScreen = ghostty.windowFullscreen
// If the previous focused window prior to creating this window is fullscreen,
// then this window also becomes fullscreen.
if let parent = focusedSurface?.window, parent.styleMask.contains(.fullScreen) {
toggleFullScreen = true
} }
if (ghostty.windowFullscreen) { if (toggleFullScreen && !window.styleMask.contains(.fullScreen)) {
// NOTE: this doesn't properly handle non-native fullscreen yet window.toggleFullScreen(nil)
c.window?.toggleFullScreen(nil)
} }
c.showWindow(self) c.showWindow(self)
// Only cascade if we aren't fullscreen. This has to be dispatched async
// because it takes one event loop tick for showWindow to work.
if (!window.styleMask.contains(.fullScreen)) {
DispatchQueue.main.async {
Self.lastCascadePoint = window.cascadeTopLeft(from: Self.lastCascadePoint)
}
}
} }
/// Creates a new tab in the current main window. If there are no windows, a window /// Creates a new tab in the current main window. If there are no windows, a window