Skip to content

Commit f0d2760

Browse files
authored
Toggling visibility is now ignored when in fullscreen mode. (#5472)
This PR ensures visibility toggling is ignored when the currently focused surface is fullscreen. This includes the following: - Show/Hide All Terminals is ignored - Using a binding to toggle is ignored This ensures Ghostty doesn't unexpectedly lose focus or disappear and is the expected behavior on macOS.
2 parents 7b593b9 + 8d31f6c commit f0d2760

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

macos/Sources/App/macOS/AppDelegate.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,21 @@ class AppDelegate: NSObject,
709709

710710
/// Toggles visibility of all Ghosty Terminal windows. When hidden, activates Ghostty as the frontmost application
711711
@IBAction func toggleVisibility(_ sender: Any) {
712+
// Toggle visibility doesn't do anything if the focused window is native
713+
// fullscreen.
714+
guard let keyWindow = NSApp.keyWindow,
715+
!keyWindow.styleMask.contains(.fullScreen) else { return }
716+
712717
// If we have focus, then we hide all windows.
713718
if NSApp.isActive {
714719
// We need to keep track of the windows that were visible because we only
715720
// want to bring back these windows if we remove the toggle.
716-
self.hiddenWindows = NSApp.windows.filter { $0.isVisible }.map { Weak($0) }
721+
//
722+
// We also ignore fullscreen windows because they don't hide anyways.
723+
self.hiddenWindows = NSApp.windows.filter {
724+
$0.isVisible &&
725+
!$0.styleMask.contains(.fullScreen)
726+
}.map { Weak($0) }
717727
NSApp.hide(nil)
718728
return
719729
}

src/input/Binding.zig

+2
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ pub const Action = union(enum) {
470470
/// Ghostty becomes focused. When hiding all windows, focus is yielded
471471
/// to the next application as determined by the OS.
472472
///
473+
/// Note: When the focused surface is fullscreen, this method does nothing.
474+
///
473475
/// This currently only works on macOS.
474476
toggle_visibility: void,
475477

0 commit comments

Comments
 (0)