mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixed profile matching for cloned displays
Weird error where having a clone causes an extra 'zeroed out' entry in the Windows Display Modes sequence. This change modifies the Windows mode info checks to allow for this situation.
This commit is contained in:
parent
dcde15e73b
commit
81f2d08fe0
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.0.1.161")]
|
||||
[assembly: AssemblyFileVersion("2.0.1.161")]
|
||||
[assembly: AssemblyVersion("2.0.1.168")]
|
||||
[assembly: AssemblyFileVersion("2.0.1.168")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
@ -1283,12 +1283,12 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
NV_COLOR_DATA_V5 colorData = colorDataDict.Value;
|
||||
UInt32 displayId = colorDataDict.Key;
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want to process HDR Colour for display {displayId}.");
|
||||
|
||||
// If this is a setting that says it will use default windows colour settings, then we turn it off
|
||||
if (colorData.ColorSelectionPolicy != NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_DEFAULT &&
|
||||
if (colorData.ColorSelectionPolicy == NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_DEFAULT &&
|
||||
ActiveDisplayConfig.ColorConfig.ColorData[displayId].ColorSelectionPolicy != colorData.ColorSelectionPolicy)
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want to turn off NVIDIA customer colour settings for display {displayId}.");
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want the standard colour settings to be {displayConfig.ColorConfig.ColorData[displayId].ColorSelectionPolicy.ToString("G")} for Mosaic display {displayId}.");
|
||||
colorData = displayConfig.ColorConfig.ColorData[displayId];
|
||||
|
||||
@ -1349,6 +1349,10 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while seting the color settings! NvAPI_Disp_ColorControl() returned error code {NVStatus}. It's most likely that your monitor {displayId} doesn't support this color mode.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want only want to turn off custom NVIDIA colour settings if needed for display {displayId}, and that currently isn't required. Skipping changing NVIDIA colour mode.");
|
||||
}
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want to turn off HDR colour if it's user set HDR colour.");
|
||||
@ -1358,10 +1362,11 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
NV_HDR_COLOR_DATA_V2 hdrColorData = hdrColorDataDict.Value;
|
||||
UInt32 displayId = hdrColorDataDict.Key;
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want to turn off HDR mode for display {displayId}.");
|
||||
// if it's not an HDR then we turn off HDR
|
||||
if (hdrColorData.HdrMode != NV_HDR_MODE.OFF && ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode != hdrColorData.HdrMode)
|
||||
if (hdrColorData.HdrMode == NV_HDR_MODE.OFF && ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode != hdrColorData.HdrMode)
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want to turn on custom HDR mode for display {displayId}.");
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: HDR mode is currently {ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode.ToString("G")} for Mosaic display {displayId}.");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want HDR settings BPC {hdrColorData.HdrBpc} for Mosaic display {displayId}");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: We want HDR settings HDR Colour Format {hdrColorData.HdrColorFormat} for Mosaic display {displayId}");
|
||||
@ -1401,6 +1406,11 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfig: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {displayId} doesn't support HDR.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want only want to turn off custom NVIDIA HDR settings if needed for display {displayId}, and that currently isn't required. Skipping changing NVIDIA HDR mode.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1422,12 +1432,12 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
NV_COLOR_DATA_V5 colorData = colorDataDict.Value;
|
||||
UInt32 displayId = colorDataDict.Key;
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to process HDR Colour for Mosaic display {displayId}.");
|
||||
|
||||
// If this is a setting that says it will use default windows colour settings, then we turn it off
|
||||
if (colorData.ColorSelectionPolicy == NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_DEFAULT &&
|
||||
ActiveDisplayConfig.ColorConfig.ColorData[displayId].ColorSelectionPolicy != NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_DEFAULT)
|
||||
// If this is a setting that says it uses user colour settings, then we turn it off
|
||||
if (colorData.ColorSelectionPolicy != NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_DEFAULT &&
|
||||
ActiveDisplayConfig.ColorConfig.ColorData[displayId].ColorSelectionPolicy != colorData.ColorSelectionPolicy)
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to use custom NVIDIA HDR Colour for display {displayId}.");
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want the standard colour settings to be {displayConfig.ColorConfig.ColorData[displayId].ColorSelectionPolicy.ToString("G")} for Mosaic display {displayId}.");
|
||||
colorData = displayConfig.ColorConfig.ColorData[displayId];
|
||||
|
||||
@ -1488,20 +1498,24 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: Some non standard error occurred while seting the color settings! NvAPI_Disp_ColorControl() returned error code {NVStatus}. It's most likely that your monitor {displayId} doesn't support this color mode.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want only want to turn on custom NVIDIA colour settings if needed for display {displayId}, and that currently isn't required. Skipping changing NVIDIA colour mode.");
|
||||
}
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to turn off HDR colour if it's user set HDR colour.");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to turn on NVIDIA HDR colour if it's user wants to use NVIDIA HDR colour.");
|
||||
// Now we try to set each display color
|
||||
foreach (var hdrColorDataDict in displayConfig.HdrConfig.HdrColorData)
|
||||
{
|
||||
NV_HDR_COLOR_DATA_V2 hdrColorData = hdrColorDataDict.Value;
|
||||
UInt32 displayId = hdrColorDataDict.Key;
|
||||
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to turn off HDR mode for Mosaic display {displayId}.");
|
||||
// if it's not an HDR then we turn off HDR
|
||||
if (hdrColorData.HdrMode == NV_HDR_MODE.OFF &&
|
||||
ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode != NV_HDR_MODE.OFF)
|
||||
// if it's HDR and it's a different mode than what we are in now, then set HDR
|
||||
if (hdrColorData.HdrMode != NV_HDR_MODE.OFF &&
|
||||
ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode != hdrColorData.HdrMode)
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want to turn on user-set HDR mode for display {displayId} as it's supposed to be on.");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: HDR mode is currently {ActiveDisplayConfig.HdrConfig.HdrColorData[displayId].HdrMode.ToString("G")} for Mosaic display {displayId}.");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want HDR settings BPC {hdrColorData.HdrBpc} for Mosaic display {displayId}");
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want HDR settings HDR Colour Format {hdrColorData.HdrColorFormat} for Mosaic display {displayId}");
|
||||
@ -1541,6 +1555,10 @@ namespace DisplayMagicianShared.NVIDIA
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: Some non standard error occurred while getting Mosaic Topology! NvAPI_Disp_HdrColorControl() returned error code {NVStatus}. It's most likely that your monitor {displayId} doesn't support HDR.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Trace($"NVIDIALibrary/SetActiveConfigOverride: We want only want to turn on custom NVIDIA HDR if needed for display {displayId} and that currently isn't required. Skipping changing NVIDIA HDR mode.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ namespace DisplayMagicianShared
|
||||
public string Name;
|
||||
public string Library;
|
||||
public bool IsPrimary;
|
||||
public bool IsClone;
|
||||
public int ClonedCopies;
|
||||
public Color Colour;
|
||||
public string DisplayConnector;
|
||||
internal bool HDRSupported;
|
||||
@ -1039,6 +1041,22 @@ namespace DisplayMagicianShared
|
||||
UInt32 sourceId = path.SourceInfo.Id;
|
||||
UInt32 targetId = path.TargetInfo.Id;
|
||||
|
||||
screen.IsClone = false;
|
||||
screen.ClonedCopies = 0;
|
||||
foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
|
||||
{
|
||||
if (displaySource.Value.Contains(sourceId))
|
||||
{
|
||||
if (displaySource.Value.Count > 1)
|
||||
{
|
||||
// We have a cloned display
|
||||
screen.IsClone = true;
|
||||
screen.ClonedCopies = displaySource.Value.Count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Go through the screens as Windows knows them, and then enhance the info with Mosaic data if it applies
|
||||
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
|
||||
@ -1269,6 +1287,21 @@ namespace DisplayMagicianShared
|
||||
UInt32 sourceId = path.SourceInfo.Id;
|
||||
UInt32 targetId = path.TargetInfo.Id;
|
||||
|
||||
screen.IsClone = false;
|
||||
screen.ClonedCopies = 0;
|
||||
foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
|
||||
{
|
||||
if (displaySource.Value.Contains(sourceId))
|
||||
{
|
||||
if (displaySource.Value.Count > 1)
|
||||
{
|
||||
// We have a cloned display
|
||||
screen.IsClone = true;
|
||||
screen.ClonedCopies = displaySource.Value.Count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Go through the screens as Windows knows them, and then enhance the info with Mosaic data if it applies
|
||||
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
|
||||
@ -1360,6 +1393,21 @@ namespace DisplayMagicianShared
|
||||
UInt32 sourceId = path.SourceInfo.Id;
|
||||
UInt32 targetId = path.TargetInfo.Id;
|
||||
|
||||
screen.IsClone = false;
|
||||
screen.ClonedCopies = 0;
|
||||
foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
|
||||
{
|
||||
if (displaySource.Value.Contains(sourceId))
|
||||
{
|
||||
if (displaySource.Value.Count > 1)
|
||||
{
|
||||
// We have a cloned display
|
||||
screen.IsClone = true;
|
||||
screen.ClonedCopies = displaySource.Value.Count;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Go through the screens as Windows knows them, and then enhance the info with Mosaic data if it applies
|
||||
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
|
||||
|
@ -207,7 +207,11 @@ namespace DisplayMagicianShared.UserControls
|
||||
{
|
||||
str = $"Primary Display{Environment.NewLine}" + str;
|
||||
}
|
||||
|
||||
if (screen.IsClone)
|
||||
{
|
||||
str = str + $"(+{screen.ClonedCopies-1} Clone)";
|
||||
}
|
||||
|
||||
DrawString(g, str, wordTextColour, selectedWordFont, wordRect.Size, wordRect.Location);
|
||||
|
||||
// Draw the position of the screen
|
||||
|
@ -637,22 +637,33 @@ namespace DisplayMagicianShared.Windows
|
||||
if (InfoType != other.InfoType)
|
||||
return false;
|
||||
|
||||
// This happens when it is a target mode info block
|
||||
if (InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET &&
|
||||
Id == other.Id &&
|
||||
TargetMode.Equals(other.TargetMode))
|
||||
return true;
|
||||
|
||||
// This happens when it is a source mode info block
|
||||
if (InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE &&
|
||||
//Id == other.Id && // Disabling this check as as the Display ID it maps to will change after a switch from surround to non-surround profile, ruining the equality match
|
||||
// Only seems to be a problem with the DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE options weirdly enough!
|
||||
SourceMode.Equals(other.SourceMode))
|
||||
return true;
|
||||
|
||||
// This happens when it is a desktop image mode info block
|
||||
if (InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_DESKTOP_IMAGE &&
|
||||
Id == other.Id &&
|
||||
DesktopImageInfo.Equals(other.DesktopImageInfo))
|
||||
return true;
|
||||
|
||||
// This happens when it is a clone - there is an extra entry with all zeros in it!
|
||||
if (InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.Zero &&
|
||||
Id == other.Id &&
|
||||
DesktopImageInfo.Equals(other.DesktopImageInfo) &&
|
||||
TargetMode.Equals(other.TargetMode) &&
|
||||
SourceMode.Equals(other.SourceMode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user