From 297582cc09cf388c5454af766b55d4f8c7004bd6 Mon Sep 17 00:00:00 2001 From: Scr3amer Date: Tue, 26 Sep 2023 08:48:57 -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 2111c947..202ed3fe 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -129,6 +129,14 @@ EARLY_ABORT_ACCURATE_MONITOR_NAME: return retval; } +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, @@ -149,7 +157,7 @@ static BOOL CALLBACK monitorCallback(HMONITOR handle, { monitor->win32.handle = handle; - if (strcmp(monitor->name, "Generic PnP Monitor") == 0) + if (!nameContainsOutputPort(monitor->name)) { possiblyMoreAccurateMonitorName = getAccurateMonitorName(mi.szDevice); if(possiblyMoreAccurateMonitorName != NULL)