macOS: Prevent app from quitting when closing window
Describe the bug
When you click the close button (red 'x') on a macOS window, the application quits.
We need to intercept the window's close event in Electron and prevent the default behavior for macOS.
Reproduction
- With a Cinny window open on macOS, click the red Close Window control in the top left corner. (Alternatively, you should be able to hit the standard Cmd-W keyboard shortcut, but that doesn't work either)
- The app will QUIT.
Expected behavior
Default macOS Behavior: When you click the close button (red 'x') on a macOS window, the application window typically closes. This is different from Windows/Linux where the app just quits.
The desired behavior is to minimize the main window to the dock, keeping the app running in the background.
Platform and versions
1. macOS
2. n.a
3. Version 4.8.0 (20250524.160420)
4. Matrix.org
Additional context
No response
Oh... I hit this issue so many times!
Wanted to check my messages wondering "WTF, where's my Cinny?!".
The desired behavior is to minimize the main window to the dock, keeping the app running in the background.
Isn't that what the orange - button is for?
@u9000-Nine no. Minimizing window minimizes... well... window. Closing window, closes... window!
There's important distinction, because closed window don't appear on window list anymore, but application is still opened. You can still hear sounds from application, and you can reopen window by clicking on application icon.
Minimized window may have separate window icon in dock. Or may not and may be minimized into application icon - depending on user's settings.
Nonetheless - closed window, does not stop application on macOS — as opposite to other systems. This is user's unconditioned reflex issue, when user is trained to click red X to close window on macOS — but in the case of this app it does something else — exits program.
How do you actually exit a program?
How do you actually exit a program?
Apple explains here:
To quit an app, choose App Name > Quit App in the menu bar. For example, choose Preview > Quit Preview (or press the keyboard shortcut Command-Q).
- https://support.apple.com/guide/mac-help/quit-apps-mchl834d18c2/mac