macos: try to save window state before sparkle restart

This commit is contained in:
Mitchell Hashimoto
2024-01-03 11:53:18 -08:00
parent a57a32cdb3
commit ae7221d680

View File

@ -1,4 +1,5 @@
import Sparkle
import Cocoa
class UpdaterDelegate: NSObject, SPUUpdaterDelegate {
func feedURLString(for updater: SPUUpdater) -> String? {
@ -8,4 +9,12 @@ class UpdaterDelegate: NSObject, SPUUpdaterDelegate {
// tip appcast URL since it is all we support.
return "https://tip.files.ghostty.dev/appcast.xml"
}
func updaterWillRelaunchApplication(_ updater: SPUUpdater) {
// When the updater is relaunching the application we want to get macOS
// to invalidate and re-encode all of our restorable state so that when
// we relaunch it uses it.
NSApp.invalidateRestorableState()
for window in NSApp.windows { window.invalidateRestorableState() }
}
}