From cf9a4d73d9b5821d49e20b4bd6ced9109c7e98f3 Mon Sep 17 00:00:00 2001 From: joevt Date: Mon, 8 May 2023 23:55:49 -0700 Subject: [PATCH] Add doSetDisplayModeTest 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 --- AllRez/main.cpp | 59 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/AllRez/main.cpp b/AllRez/main.cpp index 8dcb6a7..ca32e15 100644 --- a/AllRez/main.cpp +++ b/AllRez/main.cpp @@ -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 @@ -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 @@ -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"; @@ -5631,8 +5663,7 @@ int main(int argc, const char * argv[]) { if (doDumpAll) { DumpAllDisplaysInfo(); } - else { - } + #endif if (doIogDiagnose) {