From 7661f1dc737c231dfb71a64509e1fd259afa2974 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sat, 16 Oct 2021 21:41:34 +1300 Subject: [PATCH] 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. --- DisplayMagician/Properties/AssemblyInfo.cs | 4 ++-- DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs | 2 +- DisplayMagicianShared/Windows/WinLibrary.cs | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index 168c68a..2f073cc 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -26,8 +26,8 @@ using System.Resources; [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] // Version information -[assembly: AssemblyVersion("2.0.1.159")] -[assembly: AssemblyFileVersion("2.0.1.159")] +[assembly: AssemblyVersion("2.0.1.161")] +[assembly: AssemblyFileVersion("2.0.1.161")] [assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: CLSCompliant(true)] diff --git a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs index f435ec3..e983167 100644 --- a/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs +++ b/DisplayMagicianShared/NVIDIA/NVIDIALibrary.cs @@ -892,7 +892,7 @@ namespace DisplayMagicianShared.NVIDIA // Now we need to loop through each of the windows paths so we can record the Windows DisplayName to DisplayID mapping // This is needed for us to piece together the Screen layout for when we draw the NVIDIA screens! myDisplayConfig.DisplayNames = new Dictionary(); - foreach (KeyValuePair displaySource in WinLibrary.GetDisplaySourceNames()) + foreach (KeyValuePair> displaySource in WinLibrary.GetDisplaySourceNames()) { // Now we try to get the information about the displayIDs and map them to windows \\DISPLAY names e.g. \\DISPLAY1 string displayName = displaySource.Key; diff --git a/DisplayMagicianShared/Windows/WinLibrary.cs b/DisplayMagicianShared/Windows/WinLibrary.cs index 409eef5..fb33cea 100644 --- a/DisplayMagicianShared/Windows/WinLibrary.cs +++ b/DisplayMagicianShared/Windows/WinLibrary.cs @@ -478,7 +478,7 @@ namespace DisplayMagicianShared.Windows return windowsDisplayConfig; } - public static Dictionary GetDisplaySourceNames() + public static Dictionary> 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 DisplaySources = new Dictionary(); + Dictionary> DisplaySources = new Dictionary>(); // 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 { path.SourceInfo.Id }); + } + SharedLogger.logger.Trace($"WinLibrary/GetWindowsDisplayConfig: Found Display Source {sourceInfo.ViewGdiDeviceName} for source {path.SourceInfo.Id}."); } else