What is the best way to get the NSScreen
instance that is most likely be a projector or AirPlay display? (or even TV-Out?) I'm writing a presentation software and will need to know which screen that most likely represents the "presentation" screen.
Some options came to mind:
A. Use the second instance if there's any. Of course this will obviously won't give good results if there are more than two screens attached.
NSScreen* projectorScreen = [NSScreen mainScreen];
NSArray* screens = [NSScreen screens];
if(screens.count > 1) {
projectorScreen = screens[1];
}
B. Use the first screen if it's not the main screen. The reason behind it is that in cases of mirroring, the first screen should be the one with the highest pixel depth.
NSScreen* projectorScreen = [NSScreen mainScreen];
NSArray* screens = [NSScreen screens];
if(screens.count > 1) {
if(screens[0] != projectorScreen) {
projectorScreen = screens[0];
}
}
C. Use the lowest screen that is not the main screen. The reason is just to choose any screen that is not the main screen.
NSScreen* projectorScreen = [NSScreen mainScreen];
NSArray* screens = [NSScreen screens];
if(screens.count > 1) {
for(NSScreen* screen in screens) {
if(screen != projectorScreen) {
projectorScreen = screen;
break;
}
}
}
D. Use NSScreen
's deviceDescription
dictionary and find the biggest screen in real-world coordinates. That is divide NSDeviceSize
's width and height with NSDeviceResolution
and theoretically this should yield an area in square inches. However I'm not fully convinced that the OS knows the real-world size of each screen.
Any other suggestions?
Granted there isn't any 100% correct heuristics, but then again, picking the correct screen for most of the time should be sufficient.