Skip to content

Fix fly-away target computation to exit the full virtual desktop in mixed-orientation multi-monitor setups - #60

Draft
shanselman with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-fly-away-animation-issue
Draft

shanselman with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-fly-away-animation-issue

Conversation

Copilot AI commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Bug Fix

What was the bug?

In mixed-orientation multi-monitor layouts, Fly Away computed end positions relative to only the source monitor’s work area.
That could place windows “off” one monitor but still visible on another (e.g., lower half of a vertical secondary display).

How did you fix it?

  • Target-space correction (monitor-local ➜ virtual desktop)

    • Kept the existing direction heuristic (left/right, up/down) based on the window’s position within its current monitor.
    • Switched final offscreen target coordinates to the virtual desktop bounds so endpoints are outside all visible monitors.
  • Interop support

    • Added missing GetSystemMetrics constants in NativeMethods:
      • SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN
      • SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN
  • WindowTracker change

    • Added GetVirtualScreenBounds() and used it in ComputeFlyAwayTarget(...) when calculating final targetLeft/targetTop.
int targetLeft = moveLeft
    ? virtualScreenBounds.Left - width - OffscreenMargin
    : virtualScreenBounds.Right + OffscreenMargin;

int targetTop = moveUp
    ? virtualScreenBounds.Top - height - OffscreenMargin
    : virtualScreenBounds.Bottom + OffscreenMargin;

Copilot AI changed the title [WIP] Fix fly away animation positions window incorrectly in multi-monitor setup Fix fly-away target computation to exit the full virtual desktop in mixed-orientation multi-monitor setups May 12, 2026
Copilot AI requested a review from shanselman May 12, 2026 17:52
@shanselman

Copy link
Copy Markdown
Owner

Triage note: this is plausible, but it needs human/manual validation because the bug is specifically mixed-orientation multi-monitor Fly Away behavior. I would not take this automatically until someone verifies at least: horizontal+vertical monitor layout, windows fully leave the virtual desktop in each direction, restore still returns windows to original positions, and single-monitor behavior is unchanged.

shanselman and others added 2 commits August 18, 2026 15:48
Enumerate the live monitor topology once, choose the shortest one-axis target with conservative clearance from every display, and cover arbitrary layouts with deterministic fuzz and an independent exhaustive oracle.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@shanselman

Copy link
Copy Markdown
Owner

The branch is now current with main and hardened in f1806d5.

Production behavior now:

  • enumerates the live topology with EnumDisplayMonitors once per Fly Away operation
  • has no fixed monitor count, resolution, origin, orientation, or rectangular-layout assumption
  • evaluates safe exits at every relevant monitor edge and chooses the shortest one-axis path
  • requires a conservative 64px clearance from every monitor, not just the source display
  • preserves window size and rejects overflow-clamped candidates

Validation:

  • solution build
  • complete interop harness at 10,000 iterations
  • deterministic examples for portrait, negative-origin, staggered, L-shaped, oversized, and three-monitor dead-space layouts
  • 2,000 broad randomized layouts (1-16 monitors)
  • 300-layout independent pixel-scan optimality oracle
  • independent adversarial audit with exhaustive/randomized counterexample testing
  • x64 NativeAOT publish

No blocking geometry findings remain. This should stay draft until #74 is merged and a human verifies mixed-DPI/mixed-orientation hardware, hot-plug behavior, restore accuracy, and a Task Manager kill during Fly Away.

Bring the Windows pull-request validation gate onto this active branch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Fly away animation positions window incorrectly in multi-monitor setup (Mixed Orientation)

2 participants