In Mac OS X, every display gets a unique CGDirectDisplayID
number assigned to it. You can use CGGetActiveDisplayList(
) or [NSScreen screens]
While I'm no pro, I believe the answer is to allow Apple to notify you when the user changes displays. The info inf the callback contains flags for adding and removing CGDirectDisplayID
s.
The user shouldn't be adding or removing graphics cards during operation, so I would play with making list at startup, and whenever you get the "remove" flag set the next "add" operation to replace that ID in the list.
I'd try just printing the information you get back each time CGDisplayRegisterReconfigurationCallback
calls your function. See if you get one with a DeviceUID with a 'remove' flag, and then a subsequent call another with an 'add' flag. Checking those id's against CGGetActiveDisplayList
would also aid in understanding what's going on.
That's my best bet, hope it helps!