contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.39k stars 100 forks source link

Prevent closing window (`A-F4` or window decorating quit button) in alternate and protected mode #864

Open whisperity opened 1 year ago

whisperity commented 1 year ago

If someone quits a running ALT application (e.g., vim) then they could lose unsaved changes and such.

I used vim, mc and aptitude as "alternate mode" programs for this test.

Terminal emulator C-d A-F4 Quit button on window decoration
GNOME Terminal in normal mode ✔️ ✔️ ✔️
GNOME Terminal in alternate mode ❌ (Most likely swallowed by program?) ❓ Pop-up "Close this terminal?" ❓ Pop-up "Close this terminal?"
Konsole in normal mode ✔️ ✔️ ✔️
Konsole in alternate mode ❌ (Most likely swallowed by program?) ❓ Pop-up "There is a process running in this window..." ❓ Pop-up "There is a process running in this window..."
Kitty in normal mode ✔️ ✔️ ✔️
Kitty in alternate mode ❌ (Most likely swallowed by program?) ⚠️✔️ ⚠️✔️
Contour in normal mode ✔️ (⚠️ But pops the "Shell closed too early" printout) ✔️ (Closes without additional messages) ✔️ (Closes without additional messages)
Contour in alternate mode ❌ (Most likely swallowed by program?) ⚠️✔️ ⚠️✔️

Unfortunately I do not have the other terminal emulators at hand, and can't even install Alacritty (it's not in the official package sources), for example...

christianparpart commented 1 year ago

Oh THIS is an interesting one. Many thanks. :)

christianparpart commented 1 year ago

I think the termination protection while being in alt-screen is actually trivially implemented. This could be done as a first step.

The second one might be somewhat more complicated due to the fact that this can't be trivially implement platform independantly. The TE spawns some app (preferrably a shell) and then, if this app has spawned other apps that are still running during app termination attempt, then a warning popup could show up. hmm.... 🤔

ninjalj commented 1 year ago

konsole close confirm popup appears when the foreground process group is not the shell, so, e.g. on the normal screen attempting to close while the following is running elicits the popup:

sleep 9999

but not for the following:

sleep 9999 &
whisperity commented 1 year ago

@christianparpart It would be a good idea if the keybind-based protected mode would also prevent the closing of the shell!