Skip to content
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

macOS: Mark window as dirty when it will require a prompt on close #2723

Open
mitchellh opened this issue Nov 18, 2024 · 1 comment
Open
Labels

Comments

@mitchellh
Copy link
Contributor

Discussed in #2678

Originally posted by lilyball November 14, 2024
macOS windows can be marked as "dirty", or edited. This is typically done in a document-based app to indicate that you've made changes to the document and that closing the window will prompt you to save your changes. This is displayed as a dot in the titlebar close button:

screenshot

It also adds an indicator to the corresponding menuitem in the Window menu.

Terminal.app uses this to indicate that the window/tab will prompt if you try and close it, and that's very useful. Besides just giving me a cue before I close it, it also means I can glance at the Window menu to see if any terminal windows are doing something (I do this before e.g. telling my computer to reboot, so I can deal with it before it interrupts the shutdown). iTerm also appears to be doing this too (I haven't checked to make sure it corresponds with the prompt-on-close condition but I'd be surprised if it doesn't).

I think it would be really useful if Ghostty picked up this behavior too. I don't know how to do this in SwiftUI but I'm pretty sure this is the NSWindow.isDocumentEdited property in AppKit.

Implementation Notes

I think this will require a new apprt action so that apprt's are notified when their close state changes. Currently there is an API to pull this info but not an event-based API to push this info. So while this is tagged macOS, it will require some core work.

@mitchellh mitchellh added contributor friendly A well-scoped, approachable issue for someone looking to contributor. os/macos labels Nov 18, 2024
@mitchellh
Copy link
Contributor Author

Doing a bit of research on this one, one tricky state that will be hard to get edge triggered is whether the cursor is at a prompt. The reason that's tricky is because detection (at least) would have to happen on the termio thread which is directly responsible for IO throughput and not an area we want to slow down.

Something to think about...

@mitchellh mitchellh removed the contributor friendly A well-scoped, approachable issue for someone looking to contributor. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant