From 56eabbe2cb9683a37406a2b7566292fd35a43639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 19 Mar 2026 16:19:51 +0800 Subject: [PATCH] Brightness (Windows): queries monitor description if display name is not available --- .../brightness/brightness_windows.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/detection/brightness/brightness_windows.cpp b/src/detection/brightness/brightness_windows.cpp index eadf21efb..f5fc477fb 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -33,6 +33,12 @@ NTSYSAPI NTSTATUS WINAPI DestroyPhysicalMonitorInternal( _In_ HANDLE hMonitor ); +NTSTATUS WINAPI GetPhysicalMonitorDescription( + _In_ HANDLE hMonitor, + _In_ DWORD dwPhysicalMonitorDescriptionSizeInChars, + _Out_ LPWSTR szPhysicalMonitorDescription +); + static const char* detectWithWmi(FFlist* result) { FFWmiQuery query(L"SELECT CurrentBrightness, InstanceName FROM WmiMonitorBrightness WHERE Active = true", nullptr, FFWmiNamespace::WMI); @@ -91,7 +97,20 @@ static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, F if (NT_SUCCESS(ffDDCCIGetVCPFeature(physicalMonitor, 0x10 /* luminance */, NULL, &curr, &max))) { FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); - ffStrbufInitCopy(&brightness->name, &display->name); + if (display->name.length > 0) + ffStrbufInitCopy(&brightness->name, &display->name); + else + { + FF_LIBRARY_LOAD_SYMBOL_LAZY(gdi32, GetPhysicalMonitorDescription) + if (ffGetPhysicalMonitorDescription) + { + wchar_t description[128 /*MUST be PHYSICAL_MONITOR_DESCRIPTION_SIZE*/]; + if (NT_SUCCESS(ffGetPhysicalMonitorDescription(physicalMonitor, ARRAY_SIZE(description), description))) + ffStrbufInitWS(&brightness->name, description); + } + if (brightness->name.length == 0) + ffStrbufSetNWS(&brightness->name, deviceName.Length / 2, deviceName.Buffer); + } brightness->max = max; brightness->min = 0; brightness->current = curr;