mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-24 13:50:11 +00:00
macOS: fix ending search in menu bar does focus on surface
This commit is contained in:
@@ -645,7 +645,7 @@ extension Ghostty {
|
||||
startSearch(app, target: target, v: action.action.start_search)
|
||||
|
||||
case GHOSTTY_ACTION_END_SEARCH:
|
||||
endSearch(app, target: target)
|
||||
return endSearch(app, target: target)
|
||||
|
||||
case GHOSTTY_ACTION_SEARCH_TOTAL:
|
||||
searchTotal(app, target: target, v: action.action.search_total)
|
||||
@@ -2078,22 +2078,23 @@ extension Ghostty {
|
||||
|
||||
private static func endSearch(
|
||||
_ app: ghostty_app_t,
|
||||
target: ghostty_target_s) {
|
||||
target: ghostty_target_s) -> Bool {
|
||||
switch target.tag {
|
||||
case GHOSTTY_TARGET_APP:
|
||||
Ghostty.logger.warning("end_search does nothing with an app target")
|
||||
return
|
||||
return false
|
||||
|
||||
case GHOSTTY_TARGET_SURFACE:
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
guard let surface = target.target.surface else { return false }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return false }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
surfaceView.searchState = nil
|
||||
surfaceView.endSearch()
|
||||
}
|
||||
|
||||
return true
|
||||
default:
|
||||
assertionFailure()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ extension Ghostty {
|
||||
self.childExitedMessage = message
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func endSearch() {
|
||||
searchState = nil
|
||||
}
|
||||
|
||||
// MARK: - Placeholders
|
||||
|
||||
func focusDidChange(_ focused: Bool) {}
|
||||
|
||||
@@ -164,10 +164,7 @@ extension Ghostty {
|
||||
surfaceView: surfaceView,
|
||||
searchState: searchState,
|
||||
onClose: {
|
||||
#if canImport(AppKit)
|
||||
Ghostty.moveFocus(to: surfaceView)
|
||||
#endif
|
||||
surfaceView.searchState = nil
|
||||
surfaceView.endSearch()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -389,6 +389,11 @@ extension Ghostty {
|
||||
progressReportTimer?.invalidate()
|
||||
}
|
||||
|
||||
override func endSearch() {
|
||||
Ghostty.moveFocus(to: self)
|
||||
super.endSearch()
|
||||
}
|
||||
|
||||
override func focusDidChange(_ focused: Bool) {
|
||||
guard let surface = self.surface else { return }
|
||||
guard self.focused != focused else { return }
|
||||
|
||||
Reference in New Issue
Block a user