Skip to content

Commit 35d0cc5

Browse files
[Tool]Exhaustively check every monitor in the Monitor Report Tool (#19384)
* Check full EnumDisplayDevicesW entries * refactor code a bit * Fix spellcheck * Remove unneeded var
1 parent 0fbec1c commit 35d0cc5

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

.github/actions/spell-check/expect.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ mmsystem
12391239
mockapi
12401240
MODECHANGE
12411241
modernwpf
1242+
MODESPRUNED
12421243
Moldova
12431244
Mongala
12441245
MONITORINFO

tools/MonitorReportTool/MonitorReportTool.cpp

+65-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace FancyZonesUtils
3737

3838
void LogEnumDisplayMonitors()
3939
{
40-
Logger::log(L" ---- EnumDisplayMonitors ---- ");
40+
Logger::log(L" ---- EnumDisplayMonitors as in FancyZones ---- ");
4141

4242
auto allMonitors = FancyZonesUtils::GetAllMonitorInfo<&MONITORINFOEX::rcWork>();
4343
std::unordered_map<std::wstring, DWORD> displayDeviceIdxMap;
@@ -67,6 +67,69 @@ void LogEnumDisplayMonitors()
6767
Logger::log(L"");
6868
}
6969

70+
void LogPrintDisplayDevice(const DISPLAY_DEVICE& displayDevice, bool internal)
71+
{
72+
const bool active = displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE;
73+
const bool mirroring = displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER;
74+
const bool modesPruned = displayDevice.StateFlags & DISPLAY_DEVICE_MODESPRUNED;
75+
const bool primaryDevice = displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE;
76+
const bool removable = displayDevice.StateFlags & DISPLAY_DEVICE_REMOVABLE;
77+
const bool VGA_Compatible = displayDevice.StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE;
78+
79+
Logger::log(L"{}DeviceId: {}", internal?L"--> ":L"", std::wstring(displayDevice.DeviceID));
80+
Logger::log(L"{}DeviceKey: {}", internal?L"--> ":L"", std::wstring(displayDevice.DeviceKey));
81+
Logger::log(L"{}DeviceName: {}", internal?L"--> ":L"", std::wstring(displayDevice.DeviceName));
82+
Logger::log(L"{}DeviceString: {}", internal?L"--> ":L"", std::wstring(displayDevice.DeviceString));
83+
Logger::log(L"{}StateFlags: {}", internal?L"--> ":L"", displayDevice.StateFlags);
84+
Logger::log(L"{}active: {}", internal?L"--> ":L"", active);
85+
Logger::log(L"{}mirroring: {}", internal?L"--> ":L"", mirroring);
86+
Logger::log(L"{}modesPruned: {}", internal?L"--> ":L"", modesPruned);
87+
Logger::log(L"{}primaryDevice: {}", internal?L"--> ":L"", primaryDevice);
88+
Logger::log(L"{}removable: {}", internal?L"--> ":L"", removable);
89+
Logger::log(L"{}VGA_Compatible: {}", internal?L"--> ":L"", VGA_Compatible);
90+
Logger::log(L"");
91+
}
92+
93+
void LogExhaustiveDisplayDevices(bool use_EDD_GET_DEVICE_INTERFACE_NAME)
94+
{
95+
Logger::log(L" ---- Exhaustive EnumDisplayDevicesW {} EDD_GET_DEVICE_INTERFACE_NAME ---- ", use_EDD_GET_DEVICE_INTERFACE_NAME?L"with":L"without");
96+
DISPLAY_DEVICE displayDevice{ .cb = sizeof(DISPLAY_DEVICE) };
97+
DWORD deviceIdx = 0;
98+
while (EnumDisplayDevicesW(nullptr, deviceIdx, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME))
99+
{
100+
LogPrintDisplayDevice(displayDevice, false);
101+
DISPLAY_DEVICE displayDeviceInternal{ .cb = sizeof(DISPLAY_DEVICE) };
102+
DWORD deviceIdxInternal = 0;
103+
while (EnumDisplayDevicesW(displayDevice.DeviceName, deviceIdxInternal, &displayDeviceInternal, EDD_GET_DEVICE_INTERFACE_NAME)) {
104+
Logger::log(L"Inside {} there's:", displayDevice.DeviceName);
105+
LogPrintDisplayDevice(displayDeviceInternal, true);
106+
deviceIdxInternal++;
107+
}
108+
deviceIdx++;
109+
}
110+
}
111+
112+
void LogEnumDisplayMonitorsProper()
113+
{
114+
115+
auto allMonitors = FancyZonesUtils::GetAllMonitorInfo<&MONITORINFOEX::rcWork>();
116+
117+
Logger::log(L" ---- FancyZonesUtils::GetAllMonitorInfo ---- ");
118+
for (auto& monitorData : allMonitors)
119+
{
120+
auto monitorInfo = monitorData.second;
121+
Logger::log(L"szDevice: {}", std::wstring(monitorInfo.szDevice));
122+
Logger::log(L"cbSize: {}", monitorInfo.cbSize);
123+
Logger::log(L"dwFlags: {}", monitorInfo.dwFlags);
124+
Logger::log(L"");
125+
}
126+
127+
LogExhaustiveDisplayDevices(true);
128+
LogExhaustiveDisplayDevices(false);
129+
130+
Logger::log(L"");
131+
}
132+
70133
void LogWMIProp(IWbemClassObject* wbemClassObj, std::wstring_view prop)
71134
{
72135
if (!wbemClassObj)
@@ -453,6 +516,7 @@ void LogInfo()
453516
Logger::log(L"");
454517

455518
LogEnumDisplayMonitors();
519+
LogEnumDisplayMonitorsProper();
456520
LogWMICIMV2();
457521
LogWMI();
458522
LogCCD();

0 commit comments

Comments
 (0)