-
Notifications
You must be signed in to change notification settings - Fork 1.1k
macos: when toggling visibility, hide individual windows not app #8636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fixes ghostty-org#8414 Previously, toggling visibility on Mac was implemented via NSApp.hide(). This caused a bug where bringing up the quick terminal would unintentionally restore hidden windows. It appears making any window key and front will first unhide the app. This diff fixes the issue by first manually removing the visible windows from the window list. Windows that are ordered out aren't restored automatically when a different window (the quick terminal) is made key and front. Disclosure: I consulted GPT-5 Thinking on the trade offs between hiding the app, ordering out windows, and minaturizing windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't built or tested this yet, my review just based on the code.
windowStash.hideAll() | ||
|
||
// Deactivate the app, as we no longer have any visible windows | ||
NSApp.hide(nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to use NSApp.hide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how that's confusing. Windows are hidden with window.orderOut()
in hideAll()
, but we still need NSApp.hide(nil)
to deactivate the app and bring whatever app was running behind Ghostty in the stack to the foreground.
// We need to know the key window so that we can bring focus back to the | ||
// right window if it was hidden. | ||
self.keyWindow = if let keyWindow = NSApp.keyWindow { | ||
self.keyWindow = if let keyWindow = NSApp.keyWindow, !keyWindow.styleMask.contains(.nonactivatingPanel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning behind ignoring nonactivatingPanel
. What does Ghostty have that triggers this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quick terminal is a non-activating panel.
Fixes #8414
Previously, toggling visibility on Mac was implemented via NSApp.hide(). This caused a bug where bringing up the quick terminal would unintentionally restore hidden windows. It appears making any window key and front will first unhide the app.
This diff fixes the issue by first manually removing the visible windows from the window list. Windows that are ordered out aren't restored automatically when a different window (the quick terminal) is made key and front.
Disclosure: I consulted GPT-5 Thinking on the trade offs between hiding the app, ordering out windows, and minaturizing windows.