diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45a2c66 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +cg_utils.o +dmgroot/ +pkgroot/ +screenresolution +screenresolution-1.7dev.dmg +screenresolution-1.7dev.pkg +screenresolution.dmg +screenresolution.pkg +version-tmpl.h +version.h +*.swp diff --git a/cg_utils.c b/cg_utils.c index 4fef025..e51db46 100644 --- a/cg_utils.c +++ b/cg_utils.c @@ -46,10 +46,19 @@ size_t bitDepth(CGDisplayModeRef mode) { unsigned int configureDisplay(CGDirectDisplayID display, struct config *config, int displayNum) { unsigned int returncode = 1; - CFArrayRef allModes = CGDisplayCopyAllDisplayModes(display, NULL); + + int value = 1; + CFNumberRef number = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &value ); + CFStringRef key = kCGDisplayShowDuplicateLowResolutionModes; + CFDictionaryRef options = CFDictionaryCreate( kCFAllocatorDefault, (const void **)&key, (const void **)&number, 1, NULL, NULL ); + + CFArrayRef allModes = CGDisplayCopyAllDisplayModes(display, options); if (allModes == NULL) { NSLog(CFSTR("Error: failed trying to look up modes for display %u"), displayNum); } + CFRelease(number); + CFRelease(options); + CGDisplayModeRef newMode = NULL; CGDisplayModeRef possibleMode; diff --git a/main.c b/main.c index 339dd42..eae9384 100644 --- a/main.c +++ b/main.c @@ -20,6 +20,7 @@ #include "version.h" #include "cg_utils.h" +#include // Number of modes to list per line. #define MODES_PER_LINE 3 @@ -135,7 +136,12 @@ unsigned int listAvailableModes(CGDirectDisplayID display, int displayNum) { int numModes = 0; int i; - CFArrayRef allModes = CGDisplayCopyAllDisplayModes(display, NULL); + int value = 1; + CFNumberRef number = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &value ); + CFStringRef key = kCGDisplayShowDuplicateLowResolutionModes; + CFDictionaryRef options = CFDictionaryCreate( kCFAllocatorDefault, (const void **)&key, (const void **)&number, 1, NULL, NULL ); + + CFArrayRef allModes = CGDisplayCopyAllDisplayModes(display, options); if (allModes == NULL) { returncode = 0; } @@ -149,6 +155,9 @@ unsigned int listAvailableModes(CGDirectDisplayID display, int displayNum) { allModes ); + CFRelease(number); + CFRelease(options); + CFArraySortValues( allModesSorted, CFRangeMake(0, CFArrayGetCount(allModesSorted)), @@ -185,7 +194,7 @@ unsigned int listAvailableModes(CGDirectDisplayID display, int displayNum) { } char modestr [50]; - sprintf(modestr, "%4lux%4lux%lu@%.0f", + sprintf(modestr, "%lux%lux%lu@%.0f", CGDisplayModeGetWidth(mode), CGDisplayModeGetHeight(mode), bitDepth(mode),