Skip to content

Instantly share code, notes, and snippets.

@Eun
Created May 19, 2015 12:39
Show Gist options
  • Save Eun/bc5bfaea5dc06825c551 to your computer and use it in GitHub Desktop.
Save Eun/bc5bfaea5dc06825c551 to your computer and use it in GitHub Desktop.
DisplayInfo
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
int main (int argc, const char * argv[]) {
CGDisplayCount displayCount;
CGDirectDisplayID displays[4];
int i;
CGGetOnlineDisplayList(4, displays, &displayCount);
for (i = 0; i < displayCount; ++i) {
CGRect rect = CGDisplayBounds(displays[i]);
printf("%d: %.0fx%.0f ( ", i, rect.size.width, rect.size.height);
if (CGDisplayIsActive(displays[i]))
printf("active ");
if (CGDisplayIsAsleep(displays[i]))
printf("sleep ");
if (CGDisplayIsBuiltin(displays[i]))
printf("builtin ");
if (CGDisplayIsMain(displays[i]))
printf("main ");
if (CGDisplayIsOnline(displays[i]))
printf("online ");
printf(")\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment