Skip to content

Fix globalSummon with monitor:any moving to wrong monitor when desktop:toCurrent - #20485

Open
Criseda wants to merge 1 commit into
microsoft:mainfrom
Criseda:fix/20305-global-summon-monitor-any-desktop-tocurrent
Open

Fix globalSummon with monitor:any moving to wrong monitor when desktop:toCurrent#20485
Criseda wants to merge 1 commit into
microsoft:mainfrom
Criseda:fix/20305-global-summon-monitor-any-desktop-tocurrent

Conversation

@Criseda

@Criseda Criseda commented Jul 30, 2026

Copy link
Copy Markdown

Summary of the Pull Request

When globalSummon is invoked with monitor:any and desktop:toCurrent, MoveWindowToDesktop may reposition the window to the monitor of the current foreground window instead of keeping it on its original monitor. This fix saves the window position before summoning and restores it after the desktop move completes.

References and Relevant Issues

Closes #20305

Detailed Description of the Pull Request / Additional comments

In AppHost::HandleSummon, when the combination of MonitorBehavior::InPlace (mapped from monitor:any) and MoveToCurrentDesktop=true is detected:

  1. Save the window rect before calling SummonWindow
  2. After MoveWindowToDesktop runs on the background thread, dispatch back to the UI thread and compare the current window origin to the saved origin
  3. If the origin changed (indicating MoveWindowToDesktop moved the window to a different monitor), restore the saved position via SetWindowPos

The HWND handle is also extracted once at the top and reused throughout as a minor cleanup.

This approach was previously suggested by contributor @Weichenleeeee123 in the issue comments.

Validation Steps Performed

  • Build passes with 0 errors (only pre-existing PRI263 warnings)
  • Code formatting verified via Invoke-CodeFormat

PR Checklist

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@Criseda

Criseda commented Jul 30, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Criseda
Criseda marked this pull request as ready for review July 30, 2026 17:01
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant