From 11cd6f568d458d0e8fe66469102735a44c379c94 Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Sat, 22 Feb 2020 12:01:00 -0800 Subject: [PATCH] automatically fix small negative y screen coordinate to avoid repeated recovery --- .../PersistentWindowProcessor.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.Common/PersistentWindowProcessor.cs index a3b18c8..aca70c4 100644 --- a/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Ninjacrab.PersistentWindows.Common/PersistentWindowProcessor.cs @@ -439,6 +439,11 @@ namespace Ninjacrab.PersistentWindows.Common // compensate for GetWindowPlacement() failure to get real coordinate of snapped window RECT screenPosition = new RECT(); User32.GetWindowRect(hwnd, ref screenPosition); + if (screenPosition.Top < 0 && screenPosition.Top > -15) + { + // automatically fix small negative y coordinate to avoid repeated recovery failure + screenPosition.Top = 0; + } uint processId = 0; uint threadId = User32.GetWindowThreadProcessId(window.HWnd, out processId); @@ -518,7 +523,8 @@ namespace Ninjacrab.PersistentWindows.Common monitorApplications[displayKey][curDisplayMetrics.Key].RecoverWindowPlacement = true; } */ - monitorApplications[displayKey][curDisplayMetrics.Key].WindowPlacement = curDisplayMetrics.WindowPlacement; + //monitorApplications[displayKey][curDisplayMetrics.Key].WindowPlacement = curDisplayMetrics.WindowPlacement; + needUpdate = true; } else {