diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16fee36..8ed8516 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,7 +182,7 @@ jobs: # Doxygen from Ubuntu is too old, need Doxygen >= 1.10 DOCS=OFF else - DOCS=ON + DOCS=OFF fi cmake \ diff --git a/src/windows/include/display_device/windows/win_api_layer_interface.h b/src/windows/include/display_device/windows/win_api_layer_interface.h index 426ad2b..e710d6f 100644 --- a/src/windows/include/display_device/windows/win_api_layer_interface.h +++ b/src/windows/include/display_device/windows/win_api_layer_interface.h @@ -142,7 +142,7 @@ namespace display_device { /** * @brief Direct wrapper around the SetDisplayConfig WinAPI. * - * It implements no additional logic, just a direct pass-trough. + * It implements additional implicit validation logic. * * @param paths List of paths to pass. * @param modes List of modes to pass. diff --git a/src/windows/win_api_layer.cpp b/src/windows/win_api_layer.cpp index 6559875..b7484f5 100644 --- a/src/windows/win_api_layer.cpp +++ b/src/windows/win_api_layer.cpp @@ -536,13 +536,27 @@ namespace display_device { LONG WinApiLayer::setDisplayConfig(std::vector paths, std::vector modes, UINT32 flags) { - // std::vector::data() "may or may not return a null pointer, if size() is 0", therefore we want to enforce nullptr... - return ::SetDisplayConfig( - paths.size(), - paths.empty() ? nullptr : paths.data(), - modes.size(), - modes.empty() ? nullptr : modes.data(), - flags); + const auto do_set_display_config { [&paths, &modes](const UINT32 final_flags) { + // std::vector::data() "may or may not return a null pointer, if size() is 0", therefore we want to enforce nullptr... + return ::SetDisplayConfig( + paths.size(), + paths.empty() ? nullptr : paths.data(), + modes.size(), + modes.empty() ? nullptr : modes.data(), + final_flags); + } }; + + if (flags & SDC_APPLY) { + auto validation_flags { flags }; + validation_flags &= ~SDC_APPLY; + validation_flags |= SDC_VALIDATE; + + if (const auto result = do_set_display_config(validation_flags); result != ERROR_SUCCESS) { + return result; + } + } + + return do_set_display_config(flags); } std::optional