macos: rework toggle_visibility to better match iTerm2

Two major changes:

1. Hiding uses `NSApp.hide` which hides all windows, preserves tabs, and
   yields focus to the next app.

2. Unhiding manually tracks and brings forward only the windows we hid.
   Proper focus should be retained.
This commit is contained in:
Mitchell Hashimoto
2025-01-10 14:35:43 -08:00
parent 61a78efa83
commit 200aee9acf
4 changed files with 47 additions and 30 deletions

View File

@@ -441,10 +441,10 @@ pub const Action = union(enum) {
toggle_quick_terminal: void,
/// Show/hide all windows. If all windows become shown, we also ensure
/// Ghostty is focused.
/// Ghostty becomes focused. When hiding all windows, focus is yielded
/// to the next application as determined by the OS.
///
/// This currently only works on macOS. When hiding all windows, we do
/// not yield focus to the previous application.
/// This currently only works on macOS.
toggle_visibility: void,
/// Quit ghostty.