Given a CGDirectDisplayID returned from
CGError error = CGGetActiveDisplayList(8, directDisplayIDs, &displayCount);
for the built-in s
CGDisplayModeGetIOFlags can tell you some information of the display. The native resolutions have kDisplayModeNativeFlag set. The following will set ns to be the native resolution of the current screen of the window win.
CGDirectDisplayID sid = ((NSNumber *)[win.screen.deviceDescription
objectForKey:@"NSScreenNumber"]).unsignedIntegerValue;
CFArrayRef ms = CGDisplayCopyAllDisplayModes(sid, NULL);
CFIndex n = CFArrayGetCount(ms);
NSSize ns;
for(int i = 0; i < n; ++i){
CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(ms, i);
if(CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag){
ns.width = CGDisplayModeGetPixelWidth(m);
ns.height = CGDisplayModeGetPixelHeight(m);
break;
}
}
CFRelease(ms);