feat: implement notification-based approach for toggle window decorations
parent
b2e816ccfe
commit
6f3bb4c6b3
|
|
@ -160,6 +160,11 @@ class BaseTerminalController: NSWindowController,
|
|||
selector: #selector(ghosttyMaximizeDidToggle(_:)),
|
||||
name: .ghosttyMaximizeDidToggle,
|
||||
object: nil)
|
||||
center.addObserver(
|
||||
self,
|
||||
selector: #selector(ghosttyToggleWindowDecorations(_:)),
|
||||
name: .ghosttyToggleWindowDecorations,
|
||||
object: nil)
|
||||
|
||||
// Splits
|
||||
center.addObserver(
|
||||
|
|
@ -562,6 +567,12 @@ class BaseTerminalController: NSWindowController,
|
|||
window.zoom(nil)
|
||||
}
|
||||
|
||||
@objc private func ghosttyToggleWindowDecorations(_ notification: Notification) {
|
||||
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
|
||||
guard surfaceTree.contains(surfaceView) else { return }
|
||||
toggleWindowDecorations()
|
||||
}
|
||||
|
||||
@objc private func ghosttyDidCloseSurface(_ notification: Notification) {
|
||||
guard let target = notification.object as? Ghostty.SurfaceView else { return }
|
||||
guard let node = surfaceTree.root?.node(view: target) else { return }
|
||||
|
|
|
|||
|
|
@ -1429,8 +1429,10 @@ extension Ghostty {
|
|||
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()
|
||||
NotificationCenter.default.post(
|
||||
name: .ghosttyToggleWindowDecorations,
|
||||
object: surfaceView
|
||||
)
|
||||
|
||||
default:
|
||||
assertionFailure()
|
||||
|
|
|
|||
|
|
@ -299,17 +299,17 @@ extension Ghostty {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ClipboardContent {
|
||||
let mime: String
|
||||
let data: String
|
||||
|
||||
|
||||
static func from(content: ghostty_clipboard_content_s) -> ClipboardContent? {
|
||||
guard let mimePtr = content.mime,
|
||||
let dataPtr = content.data else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
return ClipboardContent(
|
||||
mime: String(cString: mimePtr),
|
||||
data: String(cString: dataPtr)
|
||||
|
|
@ -406,6 +406,9 @@ extension Notification.Name {
|
|||
|
||||
/// Focus the search field
|
||||
static let ghosttySearchFocus = Notification.Name("com.mitchellh.ghostty.searchFocus")
|
||||
|
||||
/// Toggle window decorations
|
||||
static let ghosttyToggleWindowDecorations = Notification.Name("com.mitchellh.ghostty.toggleWindowDecorations")
|
||||
}
|
||||
|
||||
// NOTE: I am moving all of these to Notification.Name extensions over time. This
|
||||
|
|
|
|||
Loading…
Reference in New Issue