Fixes#440
We previously weren't observing changes so they weren't being
automatically propagated. We were using an old pointer which at best
returned the wrong value and at worst crashed. I was able to make it
crash eventually, too.
This changes the fields to be properly published and observed and as a
result the config is immediately available to all users.
Fixes#366
The comment in the Swift code explains what was happening here:
> I don't know if this is the right place, but because of WindowAccessor in our
> SwiftUI hierarchy, we have a reference cycle between view and window and windows
> are never freed. When the window is closed, the window controller is deinitialized,
> so we can use this opportunity detach the view from the window and break the cycle.
An alternate solution would be to make our reference back to the window
"weak" but we appear to not be able to do that with SwiftUI property
wrappers such as `@State` and `@Binding` and so on.
This fixes two things:
1. Issue #294: cascade point for new windows is set when creating new tabs
2. Cascade point was *not* reset when closing windows, which lead to a
big "gap" appearing when, say, opening 5 windows, closing 4, opening
a new window.
Previously, this would crash. Once the crash was fixed, it would hang
because we would only show confirmation if the terminal window had
focus.
This introduces some medium complexity logic to work around this:
1. If we are the key window, then show the confirmation dialog. Done.
2. Otherwise, if any other window is a terminal window and is key,
they're going to take it so we do nothing.
3. Otherwise, if we are the first terminal window in the application
windows list, we show it even if we're not focused.