fix #184, add -enable_auto_restore_by_manual_capture command option to disable PW from auto restore for certain display config

This commit is contained in:
Kang Yu 2022-10-19 15:41:54 -07:00
parent c8a2b40bf5
commit 050d700f38
2 changed files with 7 additions and 2 deletions

View file

@ -74,6 +74,7 @@ namespace Ninjacrab.PersistentWindows.Common
private Queue<IntPtr> pendingMoveEvents = new Queue<IntPtr>(); // queue of window with possible position change for capture private Queue<IntPtr> pendingMoveEvents = new Queue<IntPtr>(); // queue of window with possible position change for capture
private HashSet<IntPtr> pendingActivateWindows = new HashSet<IntPtr>(); private HashSet<IntPtr> pendingActivateWindows = new HashSet<IntPtr>();
private HashSet<string> normalSessions = new HashSet<string>(); //normal user sessions, for differentiating full screen game session or other transient session private HashSet<string> normalSessions = new HashSet<string>(); //normal user sessions, for differentiating full screen game session or other transient session
public bool manualNormalSession = false; //user need to manually take snapshot or save/restore from db to flag normal session
private bool userMove = false; //received window event due to user move private bool userMove = false; //received window event due to user move
private bool userMovePrev = false; //prev value of userMove private bool userMovePrev = false; //prev value of userMove
private HashSet<IntPtr> tidyTabWindows = new HashSet<IntPtr>(); //tabbed windows bundled by tidytab private HashSet<IntPtr> tidyTabWindows = new HashSet<IntPtr>(); //tabbed windows bundled by tidytab
@ -1838,7 +1839,7 @@ namespace Ninjacrab.PersistentWindows.Common
return; return;
} }
if (userMovePrev) if (saveToDB || (userMovePrev && !manualNormalSession))
{ {
normalSessions.Add(curDisplayKey); normalSessions.Add(curDisplayKey);
Log.Trace("normal session {0} due to user move", curDisplayKey, userMovePrev); Log.Trace("normal session {0} due to user move", curDisplayKey, userMovePrev);
@ -1855,7 +1856,8 @@ namespace Ninjacrab.PersistentWindows.Common
private void CaptureNewDisplayConfig(string displayKey) private void CaptureNewDisplayConfig(string displayKey)
{ {
normalSessions.Add(displayKey); if (!manualNormalSession)
normalSessions.Add(displayKey);
CaptureApplicationsOnCurrentDisplays(displayKey, immediateCapture: true); CaptureApplicationsOnCurrentDisplays(displayKey, immediateCapture: true);
} }

View file

@ -123,6 +123,9 @@ namespace Ninjacrab.PersistentWindows.SystrayShell
case "-splash=0": case "-splash=0":
splash = false; splash = false;
break; break;
case "-enable_auto_restore_by_manual_capture":
pwp.manualNormalSession = true;
break;
case "-delay_start": case "-delay_start":
delay_start = 1; delay_start = 1;
break; break;