| 81 | } |
| 82 | |
| 83 | static std::optional<float> GetRefreshRateFromDWM(HWND hwnd) |
| 84 | { |
| 85 | BOOL composition_enabled; |
| 86 | if (FAILED(DwmIsCompositionEnabled(&composition_enabled))) |
| 87 | return std::nullopt; |
| 88 | |
| 89 | DWM_TIMING_INFO ti = {}; |
| 90 | ti.cbSize = sizeof(ti); |
| 91 | HRESULT hr = DwmGetCompositionTimingInfo(nullptr, &ti); |
| 92 | if (SUCCEEDED(hr)) |
| 93 | { |
| 94 | if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0) |
| 95 | return std::nullopt; |
| 96 | |
| 97 | return static_cast<float>(ti.rateRefresh.uiNumerator) / static_cast<float>(ti.rateRefresh.uiDenominator); |
| 98 | } |
| 99 | |
| 100 | return std::nullopt; |
| 101 | } |
| 102 | |
| 103 | static std::optional<float> GetRefreshRateFromMonitor(HWND hwnd) |
| 104 | { |
no outgoing calls
no test coverage detected