In Mac OS X, every display gets a unique CGDirectDisplayID
number assigned to it. You can use CGGetActiveDisplayList(
) or [NSScreen screens]
Use CFUUIDRef which can be obtained using:
CGDisplayCreateUUIDFromDisplayID(CGDirectDisplayID displayID)
and you can get the display ID back using:
CGDisplayGetDisplayIDFromUUID(CFUUIDRef uuid)
This is what I'm using to uniquely identify displays even when their CGDirectDisplayID changes, for example was plugged into a different port. These functions aren't properly documented by Apple unfortunately, but my testing on multiple Macs with multiple displays shown that the CFUUIDRef obtained is unique and consistent -even after a reboot-, regardless of whether CGDirectDisplayID changed for whatever reason.
To check if a display is new/unique, take its CGDirectDisplayID and convert it to CFUUIDRef, and then compare the UUID, it is a many-to-one relationship, many CGDirectDisplayIDs will map to a single CFUUIDRef.
These API calls are available in ApplicationServices in 10.7 - 10.12, and ColorSync since 10.13.