new feature: ctrl click pw icon to restore foreground window to its last closing position

This commit is contained in:
Kang Yu 2023-09-14 13:02:20 -07:00
parent 42533389f2
commit 5999a5bff6
3 changed files with 13 additions and 6 deletions

View file

@ -855,7 +855,7 @@ namespace PersistentWindows.Common
return offscreen;
}
private bool RecallLastKilledPosition(IntPtr hwnd)
public bool RecallLastKilledPosition(IntPtr hwnd)
{
if (deadApps.ContainsKey(curDisplayKey))
{
@ -882,8 +882,8 @@ namespace PersistentWindows.Common
// found match
RECT r = appPos.ScreenPosition;
User32.MoveWindow(hwnd, r.Left, r.Top, r.Width, r.Height, true);
Log.Error("Recover last close location\"{0}\"", GetWindowTitle(hwnd));
deadApps[curDisplayKey].RemoveAt(idx);
Log.Error("Recover last closing location\"{0}\"", GetWindowTitle(hwnd));
//deadApps[curDisplayKey].RemoveAt(idx);
return true;
}
}
@ -1730,7 +1730,7 @@ namespace PersistentWindows.Common
return fixZorder == 2 || (restoringSnapshot && fixZorder > 0);
}
private IntPtr GetForegroundWindow()
public IntPtr GetForegroundWindow()
{
IntPtr topMostWindow = User32.GetTopWindow(desktopWindow);
for (IntPtr hwnd = topMostWindow; hwnd != IntPtr.Zero; hwnd = User32.GetWindow(hwnd, 2))

View file

@ -543,6 +543,11 @@ namespace PersistentWindows.SystrayShell
pwp.FgWindowToBottom();
}
static public void RecallLastKilledPosition()
{
pwp.RecallLastKilledPosition(pwp.GetForegroundWindow());
}
static public void PauseAutoRestore()
{
pwp.pauseAutoRestore = true;

View file

@ -111,9 +111,11 @@ namespace PersistentWindows.SystrayShell
{
if (clickCount == 1 && firstClick && !doubleClick)
{
if (ctrlKeyPressed > 0 && altKeyPressed > 0)
if (ctrlKeyPressed > 0 && altKeyPressed > 0 && shiftKeyPressed == 0)
Program.FgWindowToBottom();
else
else if (ctrlKeyPressed > 0 && altKeyPressed == 0 && shiftKeyPressed == 0)
Program.RecallLastKilledPosition();
else if (ctrlKeyPressed == 0 && altKeyPressed == 0 && shiftKeyPressed == 0)
//restore unnamed(default) snapshot
Program.RestoreSnapshot(0);
}