Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions macos/Sources/Features/Terminal/BaseTerminalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ class BaseTerminalController: NSWindowController,
ghostty,
tree: newTree,
position: notification.userInfo?[Notification.Name.ghosttySurfaceDragEndedNoTargetPointKey] as? NSPoint,
confirmUndo: false)
confirmUndo: false,
inheritBackgroundOpacity: isBackgroundOpaque)
}

// MARK: Local Events
Expand Down Expand Up @@ -990,11 +991,15 @@ class BaseTerminalController: NSWindowController,
// Do nothing if in fullscreen (transparency doesn't apply in fullscreen)
guard let window, !window.styleMask.contains(.fullScreen) else { return }

// Toggle between transparent and opaque
isBackgroundOpaque.toggle()
let newValue = !isBackgroundOpaque
let controllers = NSApplication.shared.windows.compactMap {
$0.windowController as? BaseTerminalController
}

@davidsanchez222 davidsanchez222 Apr 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use TerminalController.all like you said but I found that it excluded the quick terminal. Instead, I added this logic. It computes newValue, gathers all open terminal controllers, and applies. This change did include the quick terminal


// Update our appearance
syncAppearance()
for controller in controllers {
controller.isBackgroundOpaque = newValue
controller.syncAppearance()
}
}

/// Override this to resync any appearance related properties. This will be called automatically
Expand Down
14 changes: 13 additions & 1 deletion macos/Sources/Features/Terminal/TerminalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
// Get our parent. Our parent is the one explicitly given to us,
// otherwise the focused terminal, otherwise an arbitrary one.
let parent: NSWindow? = explicitParent ?? preferredParent?.window
if let parentController = parent?.windowController as? TerminalController {
c.isBackgroundOpaque = parentController.isBackgroundOpaque
}

if let parent, parent.styleMask.contains(.fullScreen) {
// If our previous window was fullscreen then we want our new window to
Expand Down Expand Up @@ -313,8 +316,12 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
tree: SplitTree<Ghostty.SurfaceView>,
position: NSPoint? = nil,
confirmUndo: Bool = true,
inheritBackgroundOpacity: Bool? = nil
) -> TerminalController {
let c = TerminalController.init(ghostty, withSurfaceTree: tree)
if let inheritBackgroundOpacity {
c.isBackgroundOpaque = inheritBackgroundOpacity
}

// Calculate the target frame based on the tree's view bounds
let treeSize: CGSize? = tree.root?.viewBounds()
Expand Down Expand Up @@ -359,7 +366,11 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr
withTarget: ghostty,
expiresAfter: target.undoExpiration
) { ghostty in
_ = TerminalController.newWindow(ghostty, tree: tree)
_ = TerminalController.newWindow(
ghostty,
tree: tree,
inheritBackgroundOpacity: inheritBackgroundOpacity
)
}
}
}
Expand Down Expand Up @@ -394,6 +405,7 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr

// Create a new window and add it to the parent
let controller = TerminalController.init(ghostty, withBaseConfig: baseConfig)
controller.isBackgroundOpaque = parentController.isBackgroundOpaque
guard let window = controller.window else { return controller }

// If the parent is miniaturized, then macOS exhibits really strange behaviors
Expand Down
Loading