mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-24 03:58:35 +00:00
set title callback needs to use surface userdata
This commit is contained in:
@@ -22,7 +22,6 @@ struct GhosttyApp: App {
|
||||
case .ready:
|
||||
TerminalView(app: ghostty.app!)
|
||||
.modifier(WindowObservationModifier())
|
||||
.navigationTitle(ghostty.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,9 +35,6 @@ class GhosttyState: ObservableObject {
|
||||
/// The readiness value of the state.
|
||||
@Published var readiness: Readiness = .loading
|
||||
|
||||
/// The title of the window as requested by the underlying terminal.
|
||||
@Published var title: String = "Ghostty";
|
||||
|
||||
/// The ghostty global configuration.
|
||||
var config: ghostty_config_t? = nil
|
||||
|
||||
@@ -103,10 +99,10 @@ class GhosttyState: ObservableObject {
|
||||
}
|
||||
|
||||
static func setTitle(_ userdata: UnsafeMutableRawPointer?, title: UnsafePointer<CChar>?) {
|
||||
let state = Unmanaged<GhosttyState>.fromOpaque(userdata!).takeUnretainedValue()
|
||||
let surfaceView = Unmanaged<TerminalSurfaceView_Real>.fromOpaque(userdata!).takeUnretainedValue()
|
||||
guard let titleStr = String(cString: title!, encoding: .utf8) else { return }
|
||||
DispatchQueue.main.async {
|
||||
state.title = titleStr
|
||||
surfaceView.title = titleStr
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user