diff --git a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs index f7579cf..4fcdba1 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs @@ -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; diff --git a/Ninjacrab.PersistentWindows.Solution/Common/VirtualDesktop.cs b/Ninjacrab.PersistentWindows.Solution/Common/VirtualDesktop.cs index 5f6f49e..49fd97e 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/VirtualDesktop.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/VirtualDesktop.cs @@ -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;