#312, Ctrl + Shift + RestoreFromDisk to auto skip missing window

This commit is contained in:
Kang Yu 2024-04-21 23:10:03 -07:00
parent 7d77f64d79
commit 3b51f41f08
2 changed files with 15 additions and 8 deletions

View file

@ -94,7 +94,7 @@ namespace PersistentWindows.Common
private Timer restoreFinishedTimer; private Timer restoreFinishedTimer;
public bool restoringFromMem = false; // automatic restore from memory or snapshot public bool restoringFromMem = false; // automatic restore from memory or snapshot
public bool restoringFromDB = false; // manual restore from DB public bool restoringFromDB = false; // manual restore from DB
private bool autoInitialRestoreFromDB = false; public bool autoInitialRestoreFromDB = false;
public bool restoringSnapshot = false; // implies restoringFromMem public bool restoringSnapshot = false; // implies restoringFromMem
public bool showDesktop = false; // show desktop when display changes public bool showDesktop = false; // show desktop when display changes
public int fixZorder = 1; // 1 means restore z-order only for snapshot; 2 means restore z-order for all; 0 means no z-order restore at all public int fixZorder = 1; // 1 means restore z-order only for snapshot; 2 means restore z-order for all; 0 means no z-order restore at all

View file

@ -595,7 +595,9 @@ namespace PersistentWindows.SystrayShell
static public void RestoreFromDisk(bool ask_dialog) static public void RestoreFromDisk(bool ask_dialog)
{ {
if (ask_dialog || (User32.GetKeyState(0x10) & 0x8000) != 0) //shift key pressed bool ctrl_key_pressed = (User32.GetKeyState(0x11) & 0x8000) != 0;
bool shift_key_pressed = (User32.GetKeyState(0x10) & 0x8000) != 0;
if (ask_dialog || (shift_key_pressed && !ctrl_key_pressed))
{ {
var listCollection = pwp.GetDbCollections(); var listCollection = pwp.GetDbCollections();
var dlg = new DbKeySelect(); var dlg = new DbKeySelect();
@ -615,18 +617,23 @@ namespace PersistentWindows.SystrayShell
else else
{ {
pwp.dbDisplayKey = pwp.GetDisplayKey(); pwp.dbDisplayKey = pwp.GetDisplayKey();
if ((User32.GetKeyState(0x11) & 0x8000) != 0) //ctrl key pressed if (ctrl_key_pressed)
{ {
var name = EnterDbEntryName(); if (shift_key_pressed)
if (String.IsNullOrEmpty(name)) pwp.autoInitialRestoreFromDB = true;
return; else
{
var name = EnterDbEntryName();
if (String.IsNullOrEmpty(name))
return;
pwp.dbDisplayKey += name; pwp.dbDisplayKey += name;
}
} }
} }
pwp.restoringFromDB = true; pwp.restoringFromDB = true;
pwp.StartRestoreTimer(milliSecond : 2000 /*wait mouse settle still for taskbar restore*/); pwp.StartRestoreTimer(milliSecond : 1000 /*wait mouse settle still for taskbar restore*/);
} }
static public void RestoreSnapshot(int id) static public void RestoreSnapshot(int id)