cinny icon indicating copy to clipboard operation
cinny copied to clipboard

macOS: Prevent app from quitting when closing window

Open chadkoh opened this issue 1 year ago • 5 comments

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

  1. 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)
  2. 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

chadkoh avatar Jun 09 '25 16:06 chadkoh

Oh... I hit this issue so many times!

Wanted to check my messages wondering "WTF, where's my Cinny?!".

morsik avatar Mar 24 '26 11:03 morsik

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 avatar Mar 24 '26 15:03 u9000-Nine

@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.

morsik avatar Mar 24 '26 18:03 morsik

How do you actually exit a program?

u9000-Nine avatar Mar 24 '26 18:03 u9000-Nine

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

LinuxinaBit avatar Mar 24 '26 19:03 LinuxinaBit