From 9f7a40059ec87826f5c25021986f55b3d39277ac Mon Sep 17 00:00:00 2001 From: Scr3amer Date: Tue, 26 Sep 2023 08:36:40 -0400 Subject: [PATCH] Bugfix : handle localised default monitor names If your OS is not in English you won't have "Generic PnP Monitor" so the test will succeed inspite of having a localised default monitor name. I changed the test to look for the output port between parenthesis as this is how the monitor will look like when driver is installed AFAICT. --- src/win32_monitor.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 8c308ae2..a92a2080 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -182,6 +182,14 @@ char* tryGetAccurateMonitorName(const WCHAR *deviceName) return monitorName; } +BOOL nameContainsOutputPort(const char *const i_nameToCheck) +{ + const size_t nameLength = strlen(i_nameToCheck); + const char lastChar = i_nameToCheck[nameLength - 1]; + + return lastChar == ')'; // Non generic initial names contain the output port use. E.g. MonitorName(DisplayPort) +} + // Callback for EnumDisplayMonitors in createMonitor // static BOOL CALLBACK monitorCallback(HMONITOR handle, @@ -205,7 +213,7 @@ static BOOL CALLBACK monitorCallback(HMONITOR handle, monitor->win32.handle = handle; // If the monitor driver is installed, we will already have an accurate name for the monitor. - if (strcmp(monitor->name, "Generic PnP Monitor") != 0) + if (nameContainsOutputPort(monitor->name)) return TRUE; accurateMonitorName = tryGetAccurateMonitorName(mi.szDevice);