puffin icon indicating copy to clipboard operation
puffin copied to clipboard

Support closing puffin_viewer using Command-Q and Command-W

Open im-0 opened this issue 3 months ago • 3 comments

Checklist

  • [x] I have read the Contributor Guide
  • [x] I have read and agree to the Code of Conduct
  • [x] 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

im-0 avatar Sep 17 '25 06:09 im-0

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.

im-0 avatar Sep 17 '25 06:09 im-0

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

emilk avatar Sep 17 '25 07:09 emilk

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 avatar Sep 17 '25 12:09 im-0