On Thu Aug 4 07:42:25 2022 +0000, Zhiyi Zhang wrote:
No really an issue. But moving the getting the current display settings part right after getting registry settings seems more natural to me. So index == ENUM_CURRENT_SETTINGS here and then do EnumDisplaySettingsEx() in the else branch.
Yes, but this way makes it easier to later add a case with `index != ENUM_CURRENT_SETTINGS && (flags & EDS_ROTATEDMODE)` which would also skip the `CurrentDisplaySettings` call like this:
```diff if (index == ENUM_REGISTRY_SETTINGS) ret = read_registry_settings( adapter_path, devmode ); - else if (index != ENUM_CURRENT_SETTINGS) ret = user_driver->pEnumDisplaySettingsEx( device_name, index, devmode, flags ); + /* if EDS_ROTATEDMODE is not specified, enumerate modes with the same display orientation as current */ + else if (index != ENUM_CURRENT_SETTINGS && (flags & EDS_ROTATEDMODE)) ret = TRUE; else ret = user_driver->pCurrentDisplaySettings( device_name, devmode );
+ if (ret && index != ENUM_REGISTRY_SETTINGS && index != ENUM_CURRENT_SETTINGS) + { + for (ret = FALSE, mode = modes; mode && mode->dmSize && !ret; mode = NEXT_DEVMODEW(mode)) + { + if (!(flags & EDS_ROTATEDMODE) && mode->dmDisplayOrientation != devmode->dmDisplayOrientation) continue; + if (index--) continue; + memcpy( &devmode->dmFields, &mode->dmFields, devmode->dmSize - FIELD_OFFSET(DEVMODEW, dmFields) ); + ret = TRUE; + } + } + free( modes ); + ```