`globalSummon` with `"monitor": "any"` behaves as `"monitor": "toCurrent"`
Windows Terminal version
1.24.11321.0
Windows build number
10.0.19045
Other Software
Virtual desktops (native)
Steps to reproduce
- Add the following action to settings.json:
{
"command": {
"action": "globalSummon",
"desktop": "toCurrent",
"monitor": "any",
"toggleVisibility": false
},
"id": "User.MyGlobalSummon."
}
- Set the keybinding for "Show/Hide the Terminal window". I'm using
win+~(replacing quake mode). - Move a Terminal window to a particular virtual desktop and monitor.
- Switch to any virtual desktop and move an application window to the foreground on any monitor BUT the MRU Terminal window's monitor.
- Run the keyboard shortcut.
Expected Behavior
The MRU Terminal window moves to the current virtual desktop and is left where it is/was on the monitor.
Actual Behavior
The MRU Terminal window moves to the current virtual desktop and the monitor with the currently foregrounded window.
Quite possibly something we overlooked in bringing the window to the current desktop. Thanks for filing!
MG: I suspect this is somewhere SPECIFICALLY in the case for both MonitorBehavior::InPlace (which is any) and MoveToCurrentDesktop = true
I'd like to work on this. I've confirmed that the relevant combination is MonitorBehavior::InPlace with MoveToCurrentDesktop = true, and I'm evaluating a narrowly scoped fix that preserves the window placement across the virtual desktop move while leaving ToCurrent and ToMouse behavior unchanged. I'll follow up with a PR once the change is validated.
Update: I can't run the Windows Terminal integration/build tests in my current environment, so I'm pausing this attempt and releasing the issue for others rather than holding it. The investigation branch remains local; no PR was opened.
@Weichenleeeee123 do you have details of the fix?
I was considering capturing the window placement immediately after SummonWindow for MonitorBehavior::InPlace + MoveToCurrentDesktop, then restoring it on the UI thread after MoveWindowToDesktop succeeds. That should preserve the virtual desktop move without repositioning to the current monitor. I wasn't able to validate it, so please treat this as a lead rather than a confirmed fix.
I've opened PR #20485 with a fix. @Weichenleeeee123 suggestion to capture and restore the window position was the right approach. I implemented it in HandleSummon by saving the rect before SummonWindow and restoring it after MoveWindowToDesktop on the UI thread.