diff --git a/AMDInfo/Program.cs b/AMDInfo/Program.cs index 92ab870..3e38b47 100644 --- a/AMDInfo/Program.cs +++ b/AMDInfo/Program.cs @@ -52,10 +52,10 @@ static void Main(string[] args) NLog.LogManager.Configuration = config; // Start the Log file - SharedLogger.logger.Info($"AMDInfo/Main: Starting AMDInfo v1.7.7"); + SharedLogger.logger.Info($"AMDInfo/Main: Starting AMDInfo v1.7.8"); - Console.WriteLine($"\nAMDInfo v1.7.7"); + Console.WriteLine($"\nAMDInfo v1.7.8"); Console.WriteLine($"=============="); Console.WriteLine($"By Terry MacDonald 2022\n"); diff --git a/AMDInfo/Properties/AssemblyInfo.cs b/AMDInfo/Properties/AssemblyInfo.cs index 9e83287..cef937c 100644 --- a/AMDInfo/Properties/AssemblyInfo.cs +++ b/AMDInfo/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.7.0")] -[assembly: AssemblyFileVersion("1.7.7.0")] +[assembly: AssemblyVersion("1.7.8.0")] +[assembly: AssemblyFileVersion("1.7.8.0")] diff --git a/AMDInfo/WinLibrary.cs b/AMDInfo/WinLibrary.cs index a2d2177..4db6dbf 100644 --- a/AMDInfo/WinLibrary.cs +++ b/AMDInfo/WinLibrary.cs @@ -52,15 +52,15 @@ public struct DISPLAY_SOURCE : IEquatable public override bool Equals(object obj) => obj is DISPLAY_SOURCE other && this.Equals(other); public bool Equals(DISPLAY_SOURCE other) - => SourceId.Equals(other.SourceId) && - TargetId.Equals(other.TargetId) && + => //SourceId.Equals(other.SourceId) && // Source ID needs to be ignored in this case, as windows moves the source ids around :( + TargetId.Equals(other.TargetId) && DevicePath.Equals(other.DevicePath) && SourceDpiScalingRel.Equals(other.SourceDpiScalingRel); //=> true; public override int GetHashCode() { - //return 300; - return (SourceId, TargetId, DevicePath, SourceDpiScalingRel).GetHashCode(); + //return (SourceId, TargetId, DevicePath, SourceDpiScalingRel).GetHashCode(); // Source ID needs to be ignored in this case, as windows moves the source ids around :( + return (TargetId, DevicePath, SourceDpiScalingRel).GetHashCode(); } public static bool operator ==(DISPLAY_SOURCE lhs, DISPLAY_SOURCE rhs) => lhs.Equals(rhs); @@ -91,7 +91,6 @@ public bool Equals(WINDOWS_DISPLAY_CONFIG other) if (!(IsCloned == other.IsCloned && DisplayConfigPaths.SequenceEqual(other.DisplayConfigPaths) && DisplayConfigModes.SequenceEqual(other.DisplayConfigModes) && - DisplayHDRStates.SequenceEqual(other.DisplayHDRStates) && // The dictionary keys sometimes change after returning from NVIDIA Surround, so we need to only focus on comparing the values of the GDISettings. // Additionally, we had to disable the DEviceKey from the equality testing within the GDI library itself as that waould also change after changing back from NVIDIA surround // This still allows us to detect when refresh rates change, which will allow DisplayMagician to detect profile differences. @@ -101,6 +100,12 @@ public bool Equals(WINDOWS_DISPLAY_CONFIG other) return false; } + // Now we need to go through the HDR states comparing vaues, as the order changes if there is a cloned display + if (!WinLibrary.EqualButDifferentOrder(DisplayHDRStates, other.DisplayHDRStates)) + { + return false; + } + // Now we need to go through the values to make sure they are the same, but ignore the keys (as they change after each reboot!) for (int i = 0; i < DisplaySources.Count; i++) { @@ -2361,6 +2366,53 @@ private static void RefreshTrayArea(IntPtr windowHandle) Utils.SendMessage(windowHandle, Utils.WM_MOUSEMOVE, 0, (y << 16) + x); } + public static bool EqualButDifferentOrder(IList list1, IList list2) + { + + if (list1.Count != list2.Count) + { + return false; + } + + // Now we need to go through the list1, checking that all it's items are in list2 + foreach (T item1 in list1) + { + bool foundIt = false; + foreach (T item2 in list2) + { + if (item1.Equals(item2)) + { + foundIt = true; + break; + } + } + if (!foundIt) + { + return false; + } + } + + // Now we need to go through the list2, checking that all it's items are in list1 + foreach (T item2 in list2) + { + bool foundIt = false; + foreach (T item1 in list1) + { + if (item1.Equals(item2)) + { + foundIt = true; + break; + } + } + if (!foundIt) + { + return false; + } + } + + return true; + } + } [global::System.Serializable]