Handle closing second or subsequent window
Fixes #721 Fixes #1593
When a second or subsequent window is closed its documents are just closed after saving if required.
Closing a second or subsequent window (with <Alt>F4 or otherwise) only closes the focused window.
<Ctrl>Q closes all windows. Only the docs in the last closed window will be restored.
NOTE: Restarting or closing down the system still causes unsaved data to be lost as in 'master'.
Some names are changed to make clearer their function.
I don't think moving unsaved files from window A to window B is expected behaviour at all. I don't like this behaviour. Window B should:
A) Autosave all files from the window that are unsaved.
B) Ask to save them (I think this is discouraged by elementary guidelines, but it might make sense in this specific context where the user closes the window with unsaved files?)
Yeah I agree I don't think this is the expected behavior. If I'm closing a window with tabs, I would expect those tabs to close. If I wanted to keep the tabs, I'd move them to the other window.
There seems to be a couple of issues in #721:
- [ ] Ctrl + Q should quit the app entirely, not just close the last window. I believe Ctrl + W is the shortcut for closing just a window
- [ ] We should probably throw a warning when trying to close a window with unsaved documents since it's unclear what to do and we need a decision about if the files should be saved or deleted
@danirabbit @kaixoo12 Thanks for the input - I'll rework this PR accordingly. Note that with the suggested behaviour, the documents will be saved but not restored.
@danirabbit I think <Ctrl>W usually just closes the current tab (or <Ctrl><Shift>W for Terminal). <Alt>F4 closes the current window in Code and Files. You are right that <Ctrl>Q should close all windows - as it does in Files. Code needs to be fixed in this respect.
Note: The PR currently restores the doc in the last closed window, not the first opened window. Please confirm whether this is the correct behaviour.