feat: add toggle window decorations action for macOS

Implements the GHOSTTY_ACTION_TOGGLE_WINDOW_DECORATIONS action that allows
toggling the .titled style mask to enable/disable window decorations.

This provides a clean toggle functionality independent of fullscreen behavior.
pull/8620/head
Daniel 2025-09-13 08:54:36 +02:00 committed by Mitchell Hashimoto
parent 67eb480577
commit b2e816ccfe
2 changed files with 37 additions and 1 deletions

View File

@ -869,6 +869,22 @@ class BaseTerminalController: NSWindowController,
}
}
// MARK: Window Decorations
/// Toggle window decorations for this window
func toggleWindowDecorations() {
guard let window = self.window as? TerminalWindow else { return }
// Toggle the style mask to enable/disable decorations
if window.styleMask.contains(.titled) {
// Remove decorations (make window borderless)
window.styleMask.remove(.titled)
} else {
// Add decorations back
window.styleMask.insert(.titled)
}
}
// MARK: Clipboard Confirmation
@objc private func onConfirmClipboardRequest(notification: SwiftUI.Notification) {

View File

@ -627,7 +627,7 @@ extension Ghostty {
case GHOSTTY_ACTION_TOGGLE_TAB_OVERVIEW:
fallthrough
case GHOSTTY_ACTION_TOGGLE_WINDOW_DECORATIONS:
fallthrough
toggleWindowDecorations(app, target: target)
case GHOSTTY_ACTION_PRESENT_TERMINAL:
fallthrough
case GHOSTTY_ACTION_SIZE_LIMIT:
@ -1417,6 +1417,26 @@ extension Ghostty {
appDelegate.toggleQuickTerminal(self)
}
private static func toggleWindowDecorations(
_ app: ghostty_app_t,
target: ghostty_target_s
) {
switch (target.tag) {
case GHOSTTY_TARGET_APP:
Ghostty.logger.warning("toggle window decorations does nothing with an app target")
return
case GHOSTTY_TARGET_SURFACE:
guard let surface = target.target.surface else { return }
guard let surfaceView = self.surfaceView(from: surface) else { return }
guard let terminalController = surfaceView.window?.windowController as? BaseTerminalController else { return }
terminalController.toggleWindowDecorations()
default:
assertionFailure()
}
}
private static func setTitle(
_ app: ghostty_app_t,
target: ghostty_target_s,