Skip to content

Conversation

@im-0
Copy link
Contributor

@im-0 im-0 commented Sep 17, 2025

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Close puffin_viewer using Command-Q or Command-W.

Related Issues

N/A

Copy link
Collaborator

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should already be handled by eframe: cmd-q should already quit the applciation on Mac, and Alt-F4 on windows

@im-0
Copy link
Contributor Author

im-0 commented Sep 17, 2025

This should already be handled by eframe: cmd-q should already quit the applciation on Mac, and Alt-F4 on windows

Ctrl-Q/Ctrl-W currently have no effect in Linux.

@emilk
Copy link
Collaborator

emilk commented Sep 17, 2025

Oh, interesting! Then I think this should go into eframe (or even winit) so that all eframe apps can benefit from it!

This adds handling for Command-W on macOS and both Ctrl-Q and Ctrl-W on
other systems.
@im-0 im-0 force-pushed the add-quit-shortcuts branch from d0d4b54 to d85edc8 Compare September 17, 2025 12:49
@im-0
Copy link
Contributor Author

im-0 commented Sep 17, 2025

Do I understand this right: neither eframe nor winit handles Command-Q on macOS by themselves, they just receive some "close this window" event from the macOS windowing system? If this is true, we have a misunderstanding here...

Usually there are three ways to close things when you are using a modern GUI app:

  • "Close current window". The key presses in this case are handled by the windowing system and not by applications themselves. Also, this is an equivalent of pressing the [X] button in the window title bar (if any). On Windows and most Linux WMs/DEs this is done by pressing Alt-F4. Application just receives some special event from the windowing system, and not an actual key combination.
  • "Close the whole app". This is application specific, but most normal apps (like text editors, browsers, image viewers) use Ctrl-Q. If an app has multiple tabs or multiple windows, all of those are getting closed.
  • "Close the minimal closable thing that is currently in focus". Also application-specific. This is what Ctrl-W is usually used for. This closes current tab, currently open file, etc. If the smallest closable thing is a window, usually this closes the whole window. Though I encountered some annoying exceptions...

So, as I understand, you are thinking about the first case which is handled by the windowing system and already well supported by the egui stack. But I want to add an application-specific "Quit" shortcuts that are a bit more convenient than Alt-F4.

In a case of puffin_viewer there is no functional difference between the three described cases as it is just a single window per application and that is it.

P.S. I updated my patch to exclude Command-Q on macOS, as it is already working.

@im-0 im-0 requested a review from emilk September 17, 2025 12:50
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