(unsuccessful) attempt to restore window to specified virtual desktop

This commit is contained in:
Kang Yu 2023-07-15 18:47:56 -07:00
parent 523bf1d1d3
commit c5ef467e9c
2 changed files with 27 additions and 2 deletions

View file

@ -1976,7 +1976,7 @@ namespace PersistentWindows.Common
}
}
if (vd.Enabled())
if (vd.Enabled() && IsTopLevelWindow(hWnd))
{
curDisplayMetrics.Guid = vd.GetWindowDesktopId(hWnd);
}
@ -2368,6 +2368,19 @@ namespace PersistentWindows.Common
moved = true;
}
if (restoringFromDB)
{
if (vd.Enabled() && IsTopLevelWindow(hwnd))
{
Guid curVd = vd.GetWindowDesktopId(hwnd);
if (curVd != Guid.Empty && prevDisplayMetrics.Guid != Guid.Empty)
{
if (curVd != prevDisplayMetrics.Guid)
return true;
}
}
}
if (fixZorder > 0)
{
if (prevDisplayMetrics.IsTopMost != curDisplayMetrics.IsTopMost)
@ -3037,6 +3050,18 @@ namespace PersistentWindows.Common
continue;
}
if (restoringFromDB)
{
if (vd.Enabled() && IsTopLevelWindow(hWnd))
{
Guid curVd = vd.GetWindowDesktopId(hWnd);
if (curVd != Guid.Empty && prevDisplayMetrics.Guid != Guid.Empty)
{
if (curVd != prevDisplayMetrics.Guid)
vd.MoveWindowToDesktop(hWnd, prevDisplayMetrics.Guid);
}
}
}
RECT rect = prevDisplayMetrics.ScreenPosition;
WindowPlacement windowPlacement = prevDisplayMetrics.WindowPlacement;

View file

@ -62,7 +62,7 @@ namespace PersistentWindows.Common
if (hr != 0)
{
//Marshal.ThrowExceptionForHR(hr);
Log.Error("GetWindowDesktopId() call failed");
//Log.Error("GetWindowDesktopId() call failed");
}
return result;