macos: non-native fs keeps track of screen number for change screen comp

Fixes #2370

Comparing NSScreens directly was fragile. It appears that AppKit/Cocoa
can return different instances of NSScreen for the same screen for
unknown reasons between calls to windowDidChangeScreen. I don't fully
understand why this happens.

In any case, our comparison was not safe. Instad, we now keep track of
of the CGDirectDisplayID for each screen and compare those instead.
This commit is contained in:
Mitchell Hashimoto
2024-10-05 06:19:07 -10:00
parent 9971d7a93d
commit 1ae9322959
3 changed files with 9 additions and 5 deletions

View File

@@ -1,6 +1,11 @@
import Cocoa
extension NSScreen {
/// The unique CoreGraphics display ID for this screen.
var displayID: UInt32? {
deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as? UInt32
}
// Returns true if the given screen has a visible dock. This isn't
// point-in-time visible, this is true if the dock is always visible
// AND present on this screen.