mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Add baseline implementation of Automatic Termination
This commit is contained in:
@ -53,6 +53,8 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<key>MDItemKeywords</key>
|
<key>MDItemKeywords</key>
|
||||||
<string>Terminal</string>
|
<string>Terminal</string>
|
||||||
|
<key>NSSupportsAutomaticTermination</key>
|
||||||
|
<true/>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSServices</key>
|
<key>NSServices</key>
|
||||||
|
@ -234,6 +234,11 @@ extension Ghostty {
|
|||||||
|
|
||||||
// The UTTypes that can be dragged onto this view.
|
// The UTTypes that can be dragged onto this view.
|
||||||
registerForDraggedTypes(Array(Self.dropTypes))
|
registerForDraggedTypes(Array(Self.dropTypes))
|
||||||
|
|
||||||
|
// Disable Automatic Termination while we have a surface open,
|
||||||
|
// since an open surface means there’s state the user cares about
|
||||||
|
// that can’t be restored.
|
||||||
|
ProcessInfo.processInfo.disableAutomaticTermination("surface created")
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@ -261,6 +266,11 @@ extension Ghostty {
|
|||||||
|
|
||||||
guard let surface = self.surface else { return }
|
guard let surface = self.surface else { return }
|
||||||
ghostty_surface_free(surface)
|
ghostty_surface_free(surface)
|
||||||
|
|
||||||
|
// Re-enable Automatic Termination once we know this surface is
|
||||||
|
// gone, since that means we have nothing to lose if macOS decides
|
||||||
|
// to kill us.
|
||||||
|
ProcessInfo.processInfo.enableAutomaticTermination("surface freed")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close the surface early. This will free the associated Ghostty surface and the view will
|
/// Close the surface early. This will free the associated Ghostty surface and the view will
|
||||||
@ -275,6 +285,9 @@ extension Ghostty {
|
|||||||
guard let surface = self.surface else { return }
|
guard let surface = self.surface else { return }
|
||||||
ghostty_surface_free(surface)
|
ghostty_surface_free(surface)
|
||||||
self.surface = nil
|
self.surface = nil
|
||||||
|
|
||||||
|
// Same as the other call to this function in deinit
|
||||||
|
ProcessInfo.processInfo.enableAutomaticTermination("surface freed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func focusDidChange(_ focused: Bool) {
|
func focusDidChange(_ focused: Bool) {
|
||||||
|
Reference in New Issue
Block a user