From 4fc6f7ad40f5acf64ea487ea4e0bfd4251b3291b Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Sat, 21 Sep 2024 23:27:44 -0700 Subject: [PATCH] refix live/dead window handle conflict, assuming hwnd handle only uses 3 bytes --- .../Common/PersistentWindowProcessor.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs index b9882ac..1cd4d1b 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs @@ -1176,7 +1176,9 @@ namespace PersistentWindows.Common { found_conflict = true; - IntPtr fake_hwnd = (IntPtr)(((ulong)fakeHwnd << 32) + (ulong)hwnd); + IntPtr fake_hwnd = (IntPtr)((fakeHwnd << 24) | (uint)hwnd); + if (fake_hwnd == hwnd) + continue; //replace prev zorder reference of dead hwnd with new fake_hwnd in monitorApplication foreach (var hw in monitorApplications[display_key].Keys) @@ -1188,6 +1190,10 @@ namespace PersistentWindows.Common } } + //reindex + deadApps[display_key][fake_hwnd] = deadApps[display_key][hwnd]; + deadApps[display_key].Remove(hwnd); + //replace prev zorder reference in deadApps as well foreach (var kd in deadApps[display_key].Keys) { @@ -1196,12 +1202,6 @@ namespace PersistentWindows.Common if (deadApps[display_key][kd][i].PrevZorderWindow == hwnd) deadApps[display_key][kd][i].PrevZorderWindow = fake_hwnd; } - - if (kd == hwnd) - { - deadApps[display_key][fake_hwnd] = deadApps[display_key][hwnd]; - deadApps[display_key].Remove(hwnd); - } } } }