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