Note that there are some explanatory texts on larger screens.

plurals
  1. PONSScreen get the projector/TV Out/AirPlay screen?
    primarykey
    data
    text
    <p>What is the best way to get the <code>NSScreen</code> 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.</p> <p>Some options came to mind:</p> <p>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.</p> <pre><code>NSScreen* projectorScreen = [NSScreen mainScreen]; NSArray* screens = [NSScreen screens]; if(screens.count &gt; 1) { projectorScreen = screens[1]; } </code></pre> <p>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.</p> <pre><code>NSScreen* projectorScreen = [NSScreen mainScreen]; NSArray* screens = [NSScreen screens]; if(screens.count &gt; 1) { if(screens[0] != projectorScreen) { projectorScreen = screens[0]; } } </code></pre> <p>C. Use the lowest screen that is <em>not</em> the main screen. The reason is just to choose <em>any</em> screen that is <em>not</em> the main screen.</p> <pre><code>NSScreen* projectorScreen = [NSScreen mainScreen]; NSArray* screens = [NSScreen screens]; if(screens.count &gt; 1) { for(NSScreen* screen in screens) { if(screen != projectorScreen) { projectorScreen = screen; break; } } } </code></pre> <p>D. Use <code>NSScreen</code>'s <code>deviceDescription</code> dictionary and find the biggest screen in real-world coordinates. That is divide <code>NSDeviceSize</code>'s width and height with <code>NSDeviceResolution</code> 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.</p> <p>Any other suggestions?</p> <p>Granted there isn't any 100% correct heuristics, but then again, picking the correct screen for most of the time should be sufficient.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload