Skip to content

Commit

Permalink
Fixes #10199
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jul 20, 2021
1 parent 79115e2 commit 67309f0
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,23 +884,36 @@ void IslandWindow::_RestoreFullscreenPosition(const RECT rcWork)
rcWork.left - _rcWorkBeforeFullscreen.left,
rcWork.top - _rcWorkBeforeFullscreen.top);

const til::size ncSize{ GetTotalNonClientExclusiveSize(dpiWindow) };

RECT rcWorkAdjusted = rcWork;

// GH#10199 - adjust the size of the "work" rect by the size of our borders.
// We want to make sure the window is restored within the bounds of the
// monitor we're on, but it's totally fine if the invisible borders are
// outside the monitor.
rcWorkAdjusted.left -= ncSize.width<long>() / 2;
rcWorkAdjusted.right += ncSize.width<long>() / 2;
rcWorkAdjusted.top -= ncSize.height<long>() / 2;
rcWorkAdjusted.bottom += ncSize.height<long>() / 2;

// Enforce that our position is entirely within the bounds of our work area.
// Prefer the top-left be on-screen rather than bottom-right (right before left, bottom before top).
if (rcRestore.right > rcWork.right)
if (rcRestore.right > rcWorkAdjusted.right)
{
OffsetRect(&rcRestore, rcWork.right - rcRestore.right, 0);
OffsetRect(&rcRestore, rcWorkAdjusted.right - rcRestore.right, 0);
}
if (rcRestore.left < rcWork.left)
if (rcRestore.left < rcWorkAdjusted.left)
{
OffsetRect(&rcRestore, rcWork.left - rcRestore.left, 0);
OffsetRect(&rcRestore, rcWorkAdjusted.left - rcRestore.left, 0);
}
if (rcRestore.bottom > rcWork.bottom)
if (rcRestore.bottom > rcWorkAdjusted.bottom)
{
OffsetRect(&rcRestore, 0, rcWork.bottom - rcRestore.bottom);
OffsetRect(&rcRestore, 0, rcWorkAdjusted.bottom - rcRestore.bottom);
}
if (rcRestore.top < rcWork.top)
if (rcRestore.top < rcWorkAdjusted.top)
{
OffsetRect(&rcRestore, 0, rcWork.top - rcRestore.top);
OffsetRect(&rcRestore, 0, rcWorkAdjusted.top - rcRestore.top);
}

// Show the window at the computed position.
Expand Down

0 comments on commit 67309f0

Please sign in to comment.