diff --git a/CMakeLists.txt b/CMakeLists.txt index b6362afd5..e2fafbf4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -903,7 +903,6 @@ elseif(WIN32) PRIVATE "setupapi" PRIVATE "hid" PRIVATE "wtsapi32" - PRIVATE "dxva2" ) elseif(BSD) target_link_libraries(libfastfetch diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index 01e3c0314..acf6340e6 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -2,6 +2,7 @@ extern "C" { #include "brightness.h" #include "detection/displayserver/displayserver.h" +#include "common/library.h" } #include "util/windows/wmi.hpp" #include "util/windows/unicode.hpp" @@ -36,15 +37,19 @@ static const char* detectWithWmi(FFlist* result) return NULL; } -static char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result) +static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result) { + FF_LIBRARY_LOAD(dxva2, NULL, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetPhysicalMonitorsFromHMONITOR) + FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetMonitorBrightness) + FF_LIST_FOR_EACH(FFDisplayResult, display, displayServer->displays) { PHYSICAL_MONITOR physicalMonitor; - if (GetPhysicalMonitorsFromHMONITOR((HMONITOR)(uintptr_t) display->id, 1, &physicalMonitor)) + if (ffGetPhysicalMonitorsFromHMONITOR((HMONITOR)(uintptr_t) display->id, 1, &physicalMonitor)) { DWORD min = 0, curr = 0, max = 0; - if (GetMonitorBrightness(physicalMonitor.hPhysicalMonitor, &min, &curr, &max)) + if (ffGetMonitorBrightness(physicalMonitor.hPhysicalMonitor, &min, &curr, &max)) { FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result);