Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion cg_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "version.h"
#include "cg_utils.h"
#include <sys/param.h>

// Number of modes to list per line.
#define MODES_PER_LINE 3
Expand Down Expand Up @@ -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;
}
Expand All @@ -149,6 +155,9 @@ unsigned int listAvailableModes(CGDirectDisplayID display, int displayNum) {
allModes
);

CFRelease(number);
CFRelease(options);

CFArraySortValues(
allModesSorted,
CFRangeMake(0, CFArrayGetCount(allModesSorted)),
Expand Down Expand Up @@ -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),
Expand Down