Skip to content

mac: close app with cmd+q #178

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

viernullvier
Copy link
Contributor

Scope

  • Bind built-in quit action to send a close request to all open windows, ensuring that unsaved changes will prevent the app from exiting
  • Cmd+Q accelerator will be assigned automatically, no manual setup necessary

Out of scope

  • This will only enable the Quit Dune 3D menu item. There are still a number of other default menu items that are disabled, most notably the entire Edit menu (Undo/Redo, Cut/Copy/Paste/Delete/Select-All) - enabling them requires binding more of the magic built-in action names.
  • Only tested on macOS, I have no idea whether the built-in quit action is triggered on other platforms as well. if in doubt, I can just wrap it in an #ifdef.

@carrotIndustries
Copy link
Contributor

How does this interact with the save confirmation dialogs?

@viernullvier
Copy link
Contributor Author

@carrotIndustries Tested again just to be sure:

  • No unsaved changes: App will quit immediately
  • Unsaved changes, only editor open: "Save changes" dialog opens, app will not quit
  • Unsaved changes, "Save changes" dialog is already open: A second (or third, or fourth…) "Save changes" dialog is opened, app will still not quit

I don't think having multiple dialogs is what the user expects, but I can't think of an easy way to ensure only a single dialog instance (at least at this time of day).

@viernullvier
Copy link
Contributor Author

Also, I never managed to open a second standalone editor window on macOS, so I don't know what happens if multiple windows are open. Probably just one "Save changes" dialog for each window though.

@carrotIndustries
Copy link
Contributor

Dune 3D not being single-instance on mac os brings some problems:

  • The list of recent documents gets written to disk when the app closes, so when there are multiple instances, the last ones wins
  • Preferences get saved on closing the preferences window. Also, preferences won't propagate to other instances, so the preferences window will show the settings from when the instance started.

How's it with other apps such as gtk4-demo-application?

@viernullvier
Copy link
Contributor Author

I'm not sure what you mean here - Dune 3D is single-instance on macOS after all, but only when running as a packaged app: The macOS launch daemon takes care of enforcing the single-instance constraint, but it's not active when running the raw binary from the command line.

For all intents and purposes, we can consider Dune 3D a single-instance application when distributed as an app bundle (which should ideally be the default way).

As for the multiple "Save changes" popups, I think a static class member that indicates the currently active popup (either a pointer or a flag) should do the trick.

@carrotIndustries
Copy link
Contributor

Tried it myself and implementing the 'quit' action should be preceded by implementing a single confirm to close dialog as we have it in Horizon EDA:
image

Right now, we get multiple dialogs all at once with only one being usable.

@carrotIndustries
Copy link
Contributor

FYI, I'm off-and-on implementing such a dialog in Dune 3D since I wanted it sooner or later anyhow and this is a good excuse for doing so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy