terminal icon indicating copy to clipboard operation
terminal copied to clipboard

`globalSummon` with `"monitor": "any"` behaves as `"monitor": "toCurrent"`

Open stutopp opened this issue 5 months ago • 5 comments

Windows Terminal version

1.24.11321.0

Windows build number

10.0.19045

Other Software

Virtual desktops (native)

Steps to reproduce

  1. Add the following action to settings.json:
{
    "command": {
        "action": "globalSummon",
        "desktop": "toCurrent",
        "monitor": "any",
        "toggleVisibility": false
    },
    "id": "User.MyGlobalSummon."
}
  1. Set the keybinding for "Show/Hide the Terminal window". I'm using win+~ (replacing quake mode).
  2. Move a Terminal window to a particular virtual desktop and monitor.
  3. Switch to any virtual desktop and move an application window to the foreground on any monitor BUT the MRU Terminal window's monitor.
  4. 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.

stutopp avatar Jun 08 '26 21:06 stutopp

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

DHowett avatar Jun 10 '26 19:06 DHowett

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.

Weichenleeeee123 avatar Jul 16 '26 11:07 Weichenleeeee123

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 avatar Jul 16 '26 14:07 Weichenleeeee123

@Weichenleeeee123 do you have details of the fix?

stutopp avatar Jul 16 '26 22:07 stutopp

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.

Weichenleeeee123 avatar Jul 17 '26 03:07 Weichenleeeee123

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.

Criseda avatar Jul 30 '26 17:07 Criseda