mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Add delay before a title change to avoid flicker on macOS
This commit is contained in:
@ -53,6 +53,10 @@ class BaseTerminalController: NSWindowController,
|
||||
|
||||
/// Fullscreen state management.
|
||||
private(set) var fullscreenStyle: FullscreenStyle?
|
||||
|
||||
var titleChangeDelay: TimeInterval = 0.075
|
||||
|
||||
private var titleChangeTimer: Timer?
|
||||
|
||||
/// Event monitor (see individual events for why)
|
||||
private var eventMonitor: Any? = nil
|
||||
@ -260,9 +264,12 @@ class BaseTerminalController: NSWindowController,
|
||||
func titleDidChange(to: String) {
|
||||
guard let window else { return }
|
||||
|
||||
// Set the main window title
|
||||
window.title = to
|
||||
titleChangeTimer?.invalidate()
|
||||
|
||||
// Set the main window title after a small delay to prevent flicker
|
||||
titleChangeTimer = Timer.scheduledTimer(withTimeInterval: titleChangeDelay, repeats: false) { _ in
|
||||
window.title = to
|
||||
}
|
||||
}
|
||||
|
||||
func pwdDidChange(to: URL?) {
|
||||
|
@ -26,6 +26,8 @@ class TerminalController: BaseTerminalController {
|
||||
|
||||
/// The notification cancellable for focused surface property changes.
|
||||
private var surfaceAppearanceCancellables: Set<AnyCancellable> = []
|
||||
|
||||
private var toolbarTitleChangeTimer: Timer?
|
||||
|
||||
init(_ ghostty: Ghostty.App,
|
||||
withBaseConfig base: Ghostty.SurfaceConfiguration? = nil,
|
||||
@ -546,7 +548,13 @@ class TerminalController: BaseTerminalController {
|
||||
// a custom view instead, we need to re-hide it.
|
||||
window.titleVisibility = .hidden
|
||||
}
|
||||
toolbar.titleText = to
|
||||
|
||||
toolbarTitleChangeTimer?.invalidate()
|
||||
|
||||
// Set the toolbar title after a small delay to prevent flicker
|
||||
toolbarTitleChangeTimer = Timer.scheduledTimer(withTimeInterval: titleChangeDelay, repeats: false) { _ in
|
||||
toolbar.titleText = to
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user