Fixed GUI display across multiple adapters

Found a bug in the NVIDIA screen generation logic. Fixed it, then replicated the fix in AMD and Windows functions.
This commit is contained in:
Terry MacDonald 2021-12-17 12:25:02 +13:00
parent 94e8ffe338
commit da8d5de7c3
3 changed files with 38 additions and 24 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information // Version information
[assembly: AssemblyVersion("2.1.1.42")] [assembly: AssemblyVersion("2.1.1.48")]
[assembly: AssemblyFileVersion("2.1.1.42")] [assembly: AssemblyFileVersion("2.1.1.48")]
[assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]

View File

@ -23,6 +23,7 @@ namespace DisplayMagicianShared
public int ScreenWidth; public int ScreenWidth;
public int ScreenHeight; public int ScreenHeight;
public string Name; public string Name;
public string AdapterName;
public string Library; public string Library;
public bool IsPrimary; public bool IsPrimary;
public bool IsClone; public bool IsClone;
@ -997,17 +998,20 @@ namespace DisplayMagicianShared
// For each path we go through and get the relevant info we need. // For each path we go through and get the relevant info we need.
if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0) if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0)
{ {
// Set some basics about the screen
ScreenPosition screen = new ScreenPosition();
screen.Library = "NVIDIA";
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
UInt64 adapterId = path.SourceInfo.AdapterId.Value;
UInt32 sourceId = path.SourceInfo.Id; UInt32 sourceId = path.SourceInfo.Id;
UInt32 targetId = path.TargetInfo.Id; UInt32 targetId = path.TargetInfo.Id;
// Set some basics about the screen
ScreenPosition screen = new ScreenPosition();
screen.Library = "NVIDIA";
//screen.AdapterName = adapterId.ToString();
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
screen.IsClone = false; screen.IsClone = false;
screen.ClonedCopies = 0; screen.ClonedCopies = 0;
//screen.DisplayConnector = path.TargetInfo.OutputTechnology.ToString("G");
foreach (var displaySource in _windowsDisplayConfig.DisplaySources) foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
{ {
if (displaySource.Value.Contains(sourceId)) if (displaySource.Value.Contains(sourceId))
@ -1027,7 +1031,7 @@ namespace DisplayMagicianShared
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes) foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
{ {
// Find the matching Display Config Source Mode // Find the matching Display Config Source Mode
if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId) if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId && displayMode.AdapterId.Value == adapterId)
{ {
screen.Name = targetId.ToString(); screen.Name = targetId.ToString();
//screen.DisplayConnector = displayMode.DisplayConnector; //screen.DisplayConnector = displayMode.DisplayConnector;
@ -1254,17 +1258,19 @@ namespace DisplayMagicianShared
// For each path we go through and get the relevant info we need. // For each path we go through and get the relevant info we need.
if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0) if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0)
{ {
// Set some basics about the screen UInt64 adapterId = path.SourceInfo.AdapterId.Value;
ScreenPosition screen = new ScreenPosition();
screen.Library = "AMD";
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
UInt32 sourceId = path.SourceInfo.Id; UInt32 sourceId = path.SourceInfo.Id;
UInt32 targetId = path.TargetInfo.Id; UInt32 targetId = path.TargetInfo.Id;
// Set some basics about the screen
ScreenPosition screen = new ScreenPosition();
screen.Library = "AMD";
//screen.AdapterName = adapterId.ToString();
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
screen.IsClone = false; screen.IsClone = false;
screen.ClonedCopies = 0; screen.ClonedCopies = 0;
//screen.DisplayConnector = path.TargetInfo.OutputTechnology.ToString("G");
foreach (var displaySource in _windowsDisplayConfig.DisplaySources) foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
{ {
if (displaySource.Value.Contains(sourceId)) if (displaySource.Value.Contains(sourceId))
@ -1283,7 +1289,7 @@ namespace DisplayMagicianShared
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes) foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
{ {
// Find the matching Display Config Source Mode // Find the matching Display Config Source Mode
if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId) if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId && displayMode.AdapterId.Value == adapterId)
{ {
screen.Name = targetId.ToString(); screen.Name = targetId.ToString();
//screen.DisplayConnector = displayMode.DisplayConnector; //screen.DisplayConnector = displayMode.DisplayConnector;
@ -1369,17 +1375,19 @@ namespace DisplayMagicianShared
// For each path we go through and get the relevant info we need. // For each path we go through and get the relevant info we need.
if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0) if (_windowsDisplayConfig.DisplayConfigPaths.Length > 0)
{ {
// Set some basics about the screen UInt64 adapterId = path.SourceInfo.AdapterId.Value;
ScreenPosition screen = new ScreenPosition();
screen.Library = "WINDOWS";
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
UInt32 sourceId = path.SourceInfo.Id; UInt32 sourceId = path.SourceInfo.Id;
UInt32 targetId = path.TargetInfo.Id; UInt32 targetId = path.TargetInfo.Id;
// Set some basics about the screen
ScreenPosition screen = new ScreenPosition();
screen.Library = "WINDOWS";
//screen.AdapterName = adapterId.ToString();
screen.IsSpanned = false;
screen.Colour = normalScreenColor; // this is the default unless overridden by the primary screen
screen.IsClone = false; screen.IsClone = false;
screen.ClonedCopies = 0; screen.ClonedCopies = 0;
//screen.DisplayConnector = path.TargetInfo.OutputTechnology.ToString("G");
foreach (var displaySource in _windowsDisplayConfig.DisplaySources) foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
{ {
if (displaySource.Value.Contains(sourceId)) if (displaySource.Value.Contains(sourceId))
@ -1398,7 +1406,7 @@ namespace DisplayMagicianShared
foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes) foreach (DISPLAYCONFIG_MODE_INFO displayMode in _windowsDisplayConfig.DisplayConfigModes)
{ {
// Find the matching Display Config Source Mode // Find the matching Display Config Source Mode
if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId) if (displayMode.InfoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE && displayMode.Id == sourceId && displayMode.AdapterId.Value == adapterId)
{ {
screen.Name = targetId.ToString(); screen.Name = targetId.ToString();
//screen.DisplayConnector = displayMode.DisplayConnector; //screen.DisplayConnector = displayMode.DisplayConnector;

View File

@ -203,15 +203,21 @@ namespace DisplayMagicianShared.UserControls
Rectangle wordRect = new Rectangle(screen.ScreenX + screenBezel + screenWordBuffer, screen.ScreenY + screenBezel + screenWordBuffer, screen.ScreenWidth - (screenBezel * 2) - (screenWordBuffer * 2), screen.ScreenHeight - (screenBezel * 2) - (screenWordBuffer * 2)); Rectangle wordRect = new Rectangle(screen.ScreenX + screenBezel + screenWordBuffer, screen.ScreenY + screenBezel + screenWordBuffer, screen.ScreenWidth - (screenBezel * 2) - (screenWordBuffer * 2), screen.ScreenHeight - (screenBezel * 2) - (screenWordBuffer * 2));
Color wordTextColour = pickTextColorBasedOnBgColour(screen.Colour, lightTextColour, darkTextColour); Color wordTextColour = pickTextColorBasedOnBgColour(screen.Colour, lightTextColour, darkTextColour);
// Draw the name of the screen and the size of it // Draw the name of the screen and the size of it
string str = $"{screen.Name}{Environment.NewLine}{screen.ScreenWidth}×{screen.ScreenHeight}{Environment.NewLine}{screen.DisplayConnector}"; string str = $"{screen.Name}{Environment.NewLine}";
str += $"{screen.ScreenWidth}×{ screen.ScreenHeight}{ Environment.NewLine}{ screen.DisplayConnector}";
if (screen.IsPrimary) if (screen.IsPrimary)
{ {
str = $"Primary Display{Environment.NewLine}" + str; str = $"Primary Display{Environment.NewLine}" + str;
} }
if (screen.IsClone) if (screen.IsClone)
{ {
str = str + $"(+{screen.ClonedCopies-1} Clone)"; str += $"(+{screen.ClonedCopies-1} Clone)";
} }
if (!String.IsNullOrEmpty(screen.AdapterName))
{
str += $"Adapter {screen.AdapterName}{Environment.NewLine}";
}
DrawString(g, str, wordTextColour, selectedWordFont, wordRect.Size, wordRect.Location); DrawString(g, str, wordTextColour, selectedWordFont, wordRect.Size, wordRect.Location);