#335, fix random failure to display context menu

This commit is contained in:
Kang Yu 2024-06-30 17:45:39 -07:00
parent 411b73d971
commit 630c16ac57

View file

@ -313,6 +313,7 @@ namespace PersistentWindows.Common
}
curDisplayKey = GetDisplayKey();
CaptureNewDisplayConfig(curDisplayKey);
#if DEBUG
//TestSetWindowPos();
@ -792,8 +793,6 @@ namespace PersistentWindows.Common
SystemEvents.SessionSwitch += sessionSwitchEventHandler;
CaptureNewDisplayConfig(curDisplayKey);
initialized = true;
remoteSession = System.Windows.Forms.SystemInformation.TerminalServerSession;
Log.Event($"Display config is {curDisplayKey}");
@ -2436,8 +2435,8 @@ namespace PersistentWindows.Common
processCmd.Clear();
}
}
else if (time_from_last_kill_window.TotalMilliseconds < 200
|| (!userMovePrev && !immediateCapture && pendingEventCnt > MinWindowOsMoveEvents))
else if (initialized && (time_from_last_kill_window.TotalMilliseconds < 200
|| (!userMovePrev && !immediateCapture && pendingEventCnt > MinWindowOsMoveEvents)))
{
// too many pending window moves, they are probably initiated by OS instead of user,
// defer capture