Skip to content

Commit

Permalink
Add doSetDisplayModeTest
Browse files Browse the repository at this point in the history
To test method of changing current display mode to a specific mode.
It seems that you can only set modes to those that have kDisplayModeValidFlag; kDisplayModeValidForMirroringFlag is not sufficient.
Discovered while working on downsampling patches in 10.5.8. Patches for 10.4.11 and 10.6.8 were also created.
See https://forums.macrumors.com/threads/civilization-iii-on-clamshell-ibook-help-write-history.2388728/post-32149906
  • Loading branch information
joevt committed May 9, 2023
1 parent a58b6ed commit cf9a4d7
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 deletions AllRez/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ extern int iogdiagnose (int dumpToFile, const char *optarg);
}
#endif

//=================================================================================================================================
// Debugging and testing options

int notTestDisplayIndex = 0;
int testDisplayIndex = 1;

const int doSetupIOFB = 0; // 0
const int doAttributeTest = 0; // 0
const int doEdidOverrideTest = 0;
const int doParseTest = 0;
const int doDisplayPortTest = 0;
const int doDumpAll = 1; // 1
const int doIogDiagnose = 1; // 1
int doSetDisplayModeTest = 0; // 0


//=================================================================================================================================
// Linux includes

Expand Down Expand Up @@ -5218,6 +5234,34 @@ do { \
if (result) cprintf(" result:%d", (uint32_t)result);
#endif
cprintf(",\n");

if (doSetDisplayModeTest) {
if (modes[displayIndex][i].width == 2560) {
CGDisplayConfigRef config;
CGError result = CGBeginDisplayConfiguration(&config);
if (!result) {
result = CGSConfigureDisplayMode(config, display, i);
if (result) {
iprintf("Error configuring display mode %d\n", (uint32_t)result);
}
result = CGCompleteDisplayConfiguration(config, kCGConfigureForSession);
if (result) {
iprintf("Error completing configuration %d\n", (uint32_t)result);
}
else {
uint32_t modeNum;
CGSGetCurrentDisplayMode(display, &modeNum);
if (modeNum != i) {
iprintf("Set mode %d attempted but mode is %d\n", i, modeNum);
}
else {
iprintf("Set mode successful\n", i, modeNum);
}
}
}
}
}

}
OUTDENT iprintf("}; // CGSGetDisplayModeDescriptionOfLength\n");
} // CGSGetNumberOfDisplayModes
Expand Down Expand Up @@ -5501,18 +5545,6 @@ static void DisplayPortMessages(void) {
}
} // DisplayPortMessages


int notTestDisplayIndex = 0;
int testDisplayIndex = 1;

const int doSetupIOFB = 0; // 0
const int doAttributeTest = 0; // 0
const int doEdidOverrideTest = 0;
const int doParseTest = 0;
const int doDisplayPortTest = 0;
const int doDumpAll = 1; // 1
const int doIogDiagnose = 1; // 1

int main(int argc, const char * argv[]) {
// @autoreleasepool {
const char* macOSName = DarwinMajorVersion() < 12 ? "Mac OS X" : DarwinMajorVersion() < 16 ? "OS X" : "macOS";
Expand Down Expand Up @@ -5631,8 +5663,7 @@ int main(int argc, const char * argv[]) {
if (doDumpAll) {
DumpAllDisplaysInfo();
}
else {
}

#endif

if (doIogDiagnose) {
Expand Down

0 comments on commit cf9a4d7

Please # to comment.