mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-12-29 09:34:45 +00:00
NSScreen instances can be garbage collected at any time, even for screens that remain connected, making NSMapTable with weak keys unreliable for tracking per-screen state. This changes the quick terminal to use CGDisplay UUIDs as stable identifiers, keyed in a strong dictionary. Each entry stores the window frame along with screen dimensions, scale factor, and last-seen timestamp. Rules for pruning: - Entries are invalidated when screens shrink or change scale - Entries persist and update when screens grow (allowing cached state to work with larger resolutions) - Stale entries for disconnected screens expire after 14 days. - Maximum of 10 screen entries to prevent unbounded growth
10 lines
251 B
Swift
10 lines
251 B
Swift
import Foundation
|
|
|
|
extension UUID {
|
|
/// Initialize a UUID from a CFUUID.
|
|
init?(_ cfuuid: CFUUID) {
|
|
guard let uuidString = CFUUIDCreateString(nil, cfuuid) as String? else { return nil }
|
|
self.init(uuidString: uuidString)
|
|
}
|
|
}
|