mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
adjust restore try times for local/remote session with different value
This commit is contained in:
parent
c94e54f739
commit
aecc9f6e29
1 changed files with 25 additions and 5 deletions
|
@ -20,7 +20,8 @@ namespace Ninjacrab.PersistentWindows.Common
|
||||||
private const int MaxCaptureLatency = 15000; // milliseconds to wait during restore to avoid capture OS initiated move
|
private const int MaxCaptureLatency = 15000; // milliseconds to wait during restore to avoid capture OS initiated move
|
||||||
private const int MaxUserMovePerSecond = 4; // maximum speed of window move/resize by human
|
private const int MaxUserMovePerSecond = 4; // maximum speed of window move/resize by human
|
||||||
private const int MinOsMoveWindows = 5; // minimum number of moving windows to measure in order to recognize OS initiated move
|
private const int MinOsMoveWindows = 5; // minimum number of moving windows to measure in order to recognize OS initiated move
|
||||||
private const int MaxRestoreTimes = 6;
|
private const int MaxRestoreTimes = 4;
|
||||||
|
private const int MaxRestoreTimesRemote = 12;
|
||||||
|
|
||||||
// window position database
|
// window position database
|
||||||
private Dictionary<string, Dictionary<string, ApplicationDisplayMetrics>> monitorApplications = null;
|
private Dictionary<string, Dictionary<string, ApplicationDisplayMetrics>> monitorApplications = null;
|
||||||
|
@ -41,6 +42,7 @@ namespace Ninjacrab.PersistentWindows.Common
|
||||||
private bool restoringWindowPos = false; // about to restore
|
private bool restoringWindowPos = false; // about to restore
|
||||||
private int restoreTimes = 0;
|
private int restoreTimes = 0;
|
||||||
private int restoreNestLevel = 0; // nested call level
|
private int restoreNestLevel = 0; // nested call level
|
||||||
|
private bool remoteSession = false;
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
private PowerModeChangedEventHandler powerModeChangedHandler;
|
private PowerModeChangedEventHandler powerModeChangedHandler;
|
||||||
|
@ -161,15 +163,19 @@ namespace Ninjacrab.PersistentWindows.Common
|
||||||
{
|
{
|
||||||
switch (args.Reason)
|
switch (args.Reason)
|
||||||
{
|
{
|
||||||
case SessionSwitchReason.SessionLock:
|
|
||||||
case SessionSwitchReason.RemoteDisconnect:
|
case SessionSwitchReason.RemoteDisconnect:
|
||||||
|
remoteSession = false;
|
||||||
|
goto case SessionSwitchReason.SessionLock;
|
||||||
|
case SessionSwitchReason.SessionLock:
|
||||||
case SessionSwitchReason.ConsoleDisconnect:
|
case SessionSwitchReason.ConsoleDisconnect:
|
||||||
Log.Trace("Session closing: reason {0}", args.Reason);
|
Log.Trace("Session closing: reason {0}", args.Reason);
|
||||||
CancelCaptureTimer();
|
CancelCaptureTimer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SessionSwitchReason.SessionUnlock:
|
|
||||||
case SessionSwitchReason.RemoteConnect:
|
case SessionSwitchReason.RemoteConnect:
|
||||||
|
remoteSession = true;
|
||||||
|
goto case SessionSwitchReason.SessionUnlock;
|
||||||
|
case SessionSwitchReason.SessionUnlock:
|
||||||
case SessionSwitchReason.ConsoleConnect:
|
case SessionSwitchReason.ConsoleConnect:
|
||||||
Log.Trace("Session opening: reason {0}", args.Reason);
|
Log.Trace("Session opening: reason {0}", args.Reason);
|
||||||
CancelCaptureTimer();
|
CancelCaptureTimer();
|
||||||
|
@ -256,7 +262,21 @@ namespace Ninjacrab.PersistentWindows.Common
|
||||||
case User32Events.EVENT_SYSTEM_MOVESIZESTART:
|
case User32Events.EVENT_SYSTEM_MOVESIZESTART:
|
||||||
case User32Events.EVENT_SYSTEM_MOVESIZEEND:
|
case User32Events.EVENT_SYSTEM_MOVESIZEEND:
|
||||||
Log.Trace("User aborted restore by actively maneuver window");
|
Log.Trace("User aborted restore by actively maneuver window");
|
||||||
StartCaptureApplicationsOnCurrentDisplays();
|
var thread = new Thread(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (databaseLock)
|
||||||
|
{
|
||||||
|
StartCaptureApplicationsOnCurrentDisplays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
thread.Start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +616,7 @@ namespace Ninjacrab.PersistentWindows.Common
|
||||||
lock (databaseLock)
|
lock (databaseLock)
|
||||||
{
|
{
|
||||||
CancelCaptureTimer();
|
CancelCaptureTimer();
|
||||||
if (restoreTimes < MaxRestoreTimes)
|
if (restoreTimes < (remoteSession ? MaxRestoreTimesRemote : MaxRestoreTimes))
|
||||||
{
|
{
|
||||||
validDisplayKeyForCapture = GetDisplayKey();
|
validDisplayKeyForCapture = GetDisplayKey();
|
||||||
RestoreApplicationsOnCurrentDisplays(validDisplayKeyForCapture);
|
RestoreApplicationsOnCurrentDisplays(validDisplayKeyForCapture);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue