Made changes to stop Cloned displays causing CTD

Currently still can't get the cloned displays to get applied properly though. Looks like the cloned displays are not being recorded in the settings.
This commit is contained in:
Terry MacDonald
2021-10-16 21:41:34 +13:00
parent 6032be043a
commit 7661f1dc73
3 changed files with 17 additions and 6 deletions

View File

@ -478,7 +478,7 @@ namespace DisplayMagicianShared.Windows
return windowsDisplayConfig;
}
public static Dictionary<string, uint> GetDisplaySourceNames()
public static Dictionary<string, List<uint>> GetDisplaySourceNames()
{
// Get the size of the largest Active Paths and Modes arrays
SharedLogger.logger.Trace($"WinLibrary/GetWindowsDisplayConfig: Getting the size of the largest Active Paths and Modes arrays");
@ -529,7 +529,7 @@ namespace DisplayMagicianShared.Windows
}
// Prepare the empty DisplaySources dictionary
Dictionary<string, uint> DisplaySources = new Dictionary<string, uint>();
Dictionary<string, List<uint>> DisplaySources = new Dictionary<string, List<uint>>();
// Now cycle through the paths and grab the HDR state information
// and map the adapter name to adapter id
@ -547,7 +547,18 @@ namespace DisplayMagicianShared.Windows
if (err == WIN32STATUS.ERROR_SUCCESS)
{
// Store it for later
DisplaySources.Add(sourceInfo.ViewGdiDeviceName, path.SourceInfo.Id);
//DisplaySources.Add(sourceInfo.ViewGdiDeviceName, path.SourceInfo.Id);
if (DisplaySources.ContainsKey(sourceInfo.ViewGdiDeviceName))
{
// We want to add another cloned display
DisplaySources[sourceInfo.ViewGdiDeviceName].Add(path.SourceInfo.Id);
}
else
{
// We want to create a new list entry if there isn't one already there.
DisplaySources.Add(sourceInfo.ViewGdiDeviceName, new List<uint> { path.SourceInfo.Id });
}
SharedLogger.logger.Trace($"WinLibrary/GetWindowsDisplayConfig: Found Display Source {sourceInfo.ViewGdiDeviceName} for source {path.SourceInfo.Id}.");
}
else