From 7f898ce01f89e5aa38751ead579d6327e9f8489a Mon Sep 17 00:00:00 2001 From: johnseth97 <17620345+johnseth97@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:45:03 -0400 Subject: [PATCH 1/3] Basic proxy icons showing Removed changes that accidentally carried over from another local branch. Basic Proxy Icons showing --- .../Features/Terminal/BaseTerminalController.swift | 11 ++++++++++- .../Features/Terminal/TerminalController.swift | 9 +-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index ea35790fd..96c9188a7 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -232,9 +232,18 @@ class BaseTerminalController: NSWindowController, func titleDidChange(to: String) { guard let window else { return } - + // Set the main window title window.title = to + + // Get the current working directory from the focused surface + if let pwd = focusedSurface?.pwd { + // Set the window's representedURL to the current working directory + window.representedURL = URL(fileURLWithPath: pwd) + } else { + // If we don't have a pwd, set representedURL to nil + window.representedURL = nil + } } func cellSizeDidChange(to: NSSize) { diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 4aaf3e1da..0b1ff3b72 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -213,14 +213,7 @@ class TerminalController: BaseTerminalController { } // If window decorations are disabled, remove our title - if (!ghostty.config.windowDecorations) { - window.titleVisibility = .hidden - window.standardWindowButton(.closeButton)?.isHidden = true - window.standardWindowButton(.miniaturizeButton)?.isHidden = true - window.standardWindowButton(.zoomButton)?.isHidden = true - window.titlebarAppearsTransparent = true - window.styleMask.insert(.fullSizeContentView) - } + if (!ghostty.config.windowDecorations) { window.styleMask.remove(.titled) } // Terminals typically operate in sRGB color space and macOS defaults // to "native" which is typically P3. There is a lot more resources From d7331f06e3835b647d71c5e640d581e36dbf10b2 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Wed, 23 Oct 2024 08:09:01 -0400 Subject: [PATCH 2/3] bash: stop modifying HISTCONTROL in bash-preexec.sh This hack is only needed to improve the accuracy of the command argument passed to the preexec functions, and we don't use that argument in our bash shell integration script (and nor does the __bp_original_debug_trap function above, which is the only other active preexec function). See also: - https://github.com/rcaloras/bash-preexec/issues/147 - https://github.com/rcaloras/bash-preexec/issues/115 Fixes #2269 --- src/shell-integration/bash/bash-preexec.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shell-integration/bash/bash-preexec.sh b/src/shell-integration/bash/bash-preexec.sh index 641346ad9..14a677888 100644 --- a/src/shell-integration/bash/bash-preexec.sh +++ b/src/shell-integration/bash/bash-preexec.sh @@ -310,7 +310,13 @@ __bp_install() { fi # Adjust our HISTCONTROL Variable if needed. - __bp_adjust_histcontrol + # + # GHOSTTY: Don't modify HISTCONTROL. This hack is only needed to improve the + # accuracy of the command argument passed to the preexec functions, and we + # don't use that argument in our bash shell integration script (and nor does + # the __bp_original_debug_trap function above, which is the only other active + # preexec function). + #__bp_adjust_histcontrol # Issue #25. Setting debug trap for subshells causes sessions to exit for # backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash. From df7120d13064bd74c29100c51f4baa6f1fe47353 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 23 Oct 2024 10:13:35 -0700 Subject: [PATCH 3/3] macos: use notification to detect when quick terminal shows/hides Fixes #2474 --- macos/Sources/App/macOS/AppDelegate.swift | 15 +++++++++++++-- .../QuickTerminal/QuickTerminalController.swift | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 8c1f392d6..8179e1950 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -155,6 +155,14 @@ class AppDelegate: NSObject, matching: [.keyDown], handler: localEventHandler) + // Notifications + NotificationCenter.default.addObserver( + self, + selector: #selector(quickTerminalDidChangeVisibility), + name: .quickTerminalDidChangeVisibility, + object: nil + ) + // Configure user notifications let actions = [ UNNotificationAction(identifier: Ghostty.userNotificationActionShow, title: "Show") @@ -409,6 +417,11 @@ class AppDelegate: NSObject, return event } + @objc private func quickTerminalDidChangeVisibility(_ notification: Notification) { + guard let quickController = notification.object as? QuickTerminalController else { return } + self.menuQuickTerminal?.state = if (quickController.visible) { .on } else { .off } + } + //MARK: - Restorable State /// We support NSSecureCoding for restorable state. Required as of macOS Sonoma (14) but a good idea anyways. @@ -622,8 +635,6 @@ class AppDelegate: NSObject, guard let quickController = self.quickController else { return } quickController.toggle() - - self.menuQuickTerminal?.state = if (quickController.visible) { .on } else { .off } } /// Toggles visibility of all Ghosty Terminal windows. When hidden, activates Ghostty as the frontmost application diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index 13b69d000..959f17d4a 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -140,6 +140,12 @@ class QuickTerminalController: BaseTerminalController { guard !visible else { return } visible = true + // Notify the change + NotificationCenter.default.post( + name: .quickTerminalDidChangeVisibility, + object: self + ) + // If we have a previously focused application and it isn't us, then // we want to store it so we can restore state later. if !NSApp.isActive { @@ -170,6 +176,12 @@ class QuickTerminalController: BaseTerminalController { guard visible else { return } visible = false + // Notify the change + NotificationCenter.default.post( + name: .quickTerminalDidChangeVisibility, + object: self + ) + animateWindowOut(window: window, to: position) } @@ -350,3 +362,8 @@ class QuickTerminalController: BaseTerminalController { syncAppearance() } } + +extension Notification.Name { + /// The quick terminal did become hidden or visible. + static let quickTerminalDidChangeVisibility = Notification.Name("QuickTerminalDidChangeVisibility") +}