Skip to content

Commit

Permalink
These are some changes from #4354. Maybe I wasn't that far off here?
Browse files Browse the repository at this point in the history
  Mike what are you doing

  These changes make conpty reprint less when the buffer resizes. This works
  largely quite well tbh. The biggest problem is that the input line seems to
  move, and that's no good. Presumably that's because the cursor position moved
  in conpty, but we didn't update the terminal appropriately. That can be fixed.

  This is also a horrible idea and I'm sure will come back to bite me, but hey
  lets try it.

  But seriously, this works really well for fast resizing (I mean, not including
  the cursor position thing). Didn't check maximize/restore yet but I bet that's
  _just wrong_ right now.
  • Loading branch information
zadjii-msft committed Mar 4, 2020
1 parent 1470abe commit 646a63b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
10 changes: 9 additions & 1 deletion src/host/getset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,15 @@ void ApiRoutines::GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& cont
{
// TODO: MSFT: 9574827 - shouldn't we be looking at or at least logging the failure codes here? (Or making them non-void?)
context.PostUpdateWindowSize();
WriteToScreen(context, context.GetViewport());

// Use WriteToScreen to invalidate the viewport with the renderer.
// GH#3490 - If we're in conpty mode, don't invalidate the entire
// viewport. In conpty mode, the VtEngine will later decide what
// part of the buffer actually needs to be re-sent to the terminal.
if (!g.getConsoleInformation().IsInVtIoMode())
{
WriteToScreen(context, context.GetViewport());
}
}
return S_OK;
}
Expand Down
9 changes: 7 additions & 2 deletions src/host/screenInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2176,8 +2176,13 @@ void SCREEN_INFORMATION::SetDefaultAttributes(const TextAttribute& attributes,
commandLine.UpdatePopups(attributes, popupAttributes, oldPrimaryAttributes, oldPopupAttributes);
}

// force repaint of entire viewport
GetRenderTarget().TriggerRedrawAll();
// Force repaint of entire viewport, unless we're in conpty mode. In that
// case, we don't really need to force a redraw of the entire screen just
// because the text attributes changed.
if (!gci.IsInVtIoMode())
{
GetRenderTarget().TriggerRedrawAll();
}

gci.ConsoleIme.RefreshAreaAttributes();

Expand Down
38 changes: 6 additions & 32 deletions src/renderer/vt/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,38 +278,12 @@ VtEngine::VtEngine(_In_ wil::unique_hfile pipe,
// lead to the first _actual_ resize being suppressed.
_suppressResizeRepaint = false;

if (SUCCEEDED(hr))
{
// Viewport is smaller now - just update it all.
if (oldView.Height() > newView.Height() || oldView.Width() > newView.Width())
{
hr = InvalidateAll();
}
else
{
// At least one of the directions grew.
// First try and add everything to the right of the old viewport,
// then everything below where the old viewport ended.
if (oldView.Width() < newView.Width())
{
short left = oldView.RightExclusive();
short top = 0;
short right = newView.RightInclusive();
short bottom = oldView.BottomInclusive();
Viewport rightOfOldViewport = Viewport::FromInclusive({ left, top, right, bottom });
hr = _InvalidCombine(rightOfOldViewport);
}
if (SUCCEEDED(hr) && oldView.Height() < newView.Height())
{
short left = 0;
short top = oldView.BottomExclusive();
short right = newView.RightInclusive();
short bottom = newView.BottomInclusive();
Viewport belowOldViewport = Viewport::FromInclusive({ left, top, right, bottom });
hr = _InvalidCombine(belowOldViewport);
}
}
}
// GH#3490 - When the viewport width changed, don't do anything extra here.
// If the buffer had areas that were invalid due to the resize, then the
// buffer will have triggered it's own invalidations for what it knows is
// invalid. Previously, we'd invalidate everything if the width changed,
// because we couldn't be sure if lines were reflowed.

_resized = true;
return hr;
}
Expand Down

0 comments on commit 646a63b

Please sign in to comment.