mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixed potential bug with window taskbar location during screen generation
There is a possibility that there are two displays with the same UID. This happens with software created displays such as SpaceDesk and Superdisplay. This means that we need to try and figure out which screen is the right screen, and then when we know which screen we were really wanting to
This commit is contained in:
parent
d98730a9b2
commit
cb43f74629
@ -26,8 +26,8 @@ using System.Resources;
|
||||
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("2.4.0.26")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.26")]
|
||||
[assembly: AssemblyVersion("2.4.0.28")]
|
||||
[assembly: AssemblyFileVersion("2.4.0.28")]
|
||||
[assembly: NeutralResourcesLanguageAttribute( "en" )]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
|
@ -1558,8 +1558,16 @@ namespace DisplayMagicianShared
|
||||
// rather than the MMStuckRect reg keys
|
||||
try
|
||||
{
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tb => tb.Value.RegKeyValue.Contains("Settings")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on the primary display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
if (_windowsDisplayConfig.TaskBarLayout.Count(tbr => tbr.Value.RegKeyValue.Contains("Settings")) > 0)
|
||||
{
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tbr => tbr.Value.RegKeyValue.Contains("Settings")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on the primary display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"ProfileItem/GetWindowsScreenPositions: Problem trying to get the position of the taskbar on primary display {targetId}. Assuming it's on the bottom edge.");
|
||||
screen.TaskBarEdge = TaskBarLayout.TaskBarEdge.Bottom;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1573,8 +1581,51 @@ namespace DisplayMagicianShared
|
||||
{
|
||||
try
|
||||
{
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tbr => tbr.Value.RegKeyValue.Contains($"UID{targetId}")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
int numMatches = _windowsDisplayConfig.TaskBarLayout.Count(tbr => tbr.Value.RegKeyValue.Contains($"UID{targetId}"));
|
||||
if (numMatches > 1)
|
||||
{
|
||||
var matchingTbls = (from tbl in _windowsDisplayConfig.TaskBarLayout where tbl.Value.RegKeyValue.Contains($"UID{targetId}") select tbl.Value).ToList();
|
||||
bool foundIt = false;
|
||||
foreach (var matchingTbl in matchingTbls)
|
||||
{
|
||||
// find display source that matches.
|
||||
foreach (var displaySource in _windowsDisplayConfig.DisplaySources)
|
||||
{
|
||||
foreach (var displayDevice in displaySource.Value)
|
||||
{
|
||||
// We want to find the displaydevice that has the same adapter id
|
||||
if (displayDevice.AdapterId.Value == adapterId && displayDevice.DevicePath.Contains(matchingTbl.RegKeyValue))
|
||||
{
|
||||
// This is the actual display we want!
|
||||
foundIt = true;
|
||||
screen.TaskBarEdge = matchingTbl.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If we've found it already then stop looking
|
||||
if (foundIt)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!foundIt)
|
||||
{
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tbr => tbr.Value.RegKeyValue.Contains($"UID{targetId}")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Couldn't find the taskbar location for display {targetId} when it had multiple matching UIDs. Assuming the screen edge is at the bottom of the screen.");
|
||||
}
|
||||
}
|
||||
else if (numMatches == 1)
|
||||
{
|
||||
screen.TaskBarEdge = _windowsDisplayConfig.TaskBarLayout.First(tbr => tbr.Value.RegKeyValue.Contains($"UID{targetId}")).Value.Edge;
|
||||
SharedLogger.logger.Trace($"ProfileItem/GetWindowsScreenPositions: Position of the taskbar on display {targetId} is on the {screen.TaskBarEdge } of the screen.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"ProfileItem/GetWindowsScreenPositions: Problem trying to get the position of the taskbar on display {targetId} as UID doesn't exist. Assuming it's on the bottom edge.");
|
||||
screen.TaskBarEdge = TaskBarLayout.TaskBarEdge.Bottom;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -356,6 +356,7 @@ namespace DisplayMagicianShared
|
||||
{
|
||||
SaveProfiles();
|
||||
IsPossibleRefresh();
|
||||
UpdateActiveProfile();
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
@ -438,6 +439,7 @@ namespace DisplayMagicianShared
|
||||
{
|
||||
SaveProfiles();
|
||||
IsPossibleRefresh();
|
||||
UpdateActiveProfile();
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
@ -519,6 +521,7 @@ namespace DisplayMagicianShared
|
||||
{
|
||||
SaveProfiles();
|
||||
IsPossibleRefresh();
|
||||
UpdateActiveProfile();
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
|
@ -727,7 +727,7 @@ namespace DisplayMagicianShared.Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Error($"TaskBarLayout/GetAllCurrentTaskBarPositions: Skipping grabbing Taskbar position from a cloned display {monitorInfo.szDevice}");
|
||||
SharedLogger.logger.Trace($"TaskBarLayout/GetAllCurrentTaskBarPositions: Skipping grabbing Taskbar position from a cloned display {monitorInfo.szDevice}");
|
||||
}
|
||||
|
||||
// Prep the next taskbar window so we continue through them
|
||||
|
Loading…
Reference in New Issue
Block a user