Created
July 1, 2012 10:26
-
-
Save garethjenkins/3027840 to your computer and use it in GitHub Desktop.
enumerate displays using CGGetActiveDisplayList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGDirectDisplayID displays[MAX_DISPLAYS]; | |
uint32_t numDisplays; | |
uint32_t i; | |
CGGetActiveDisplayList(MAX_DISPLAYS, displays, &numDisplays); | |
for(i=0; i<numDisplays; i++) | |
{ | |
CGDisplayModeRef mode; | |
CFIndex index, count; | |
CFArrayRef modeList; | |
modeList=CGDisplayCopyAllDisplayModes(displays[i], NULL); | |
count=CFArrayGetCount(modeList); | |
NSLog(@"\n\nmode --"); | |
for(index=0;index<count;index++) | |
{ | |
mode=(CGDisplayModeRef)CFArrayGetValueAtIndex(modeList, index); | |
long h=0, w=0; | |
h=CGDisplayModeGetHeight(mode); | |
w=CGDisplayModeGetWidth(mode); | |
uint32_t flags=CGDisplayModeGetIOFlags(mode); | |
NSLog(@"flags: %d", flags); | |
NSLog(@"w, h: %ld, %ld", w, h); | |
//test mode here against required params and set, using: | |
//CGDisplaySetDisplayMode(displays[i], mode, NULL); | |
} | |
CFRelease(modeList); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based pretty much entirely on the Quartz Display Services doc here https://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayModes.html#//apple_ref/doc/uid/TP40004234-SW1