Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the cursor invalidation region #14661

Merged
1 commit merged into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/renderer/base/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,16 @@ void Renderer::TriggerRedrawCursor(const til::point* const pcoord)
// cells for the cursor, taking line rendition into account.
const auto lineRendition = buffer.GetLineRendition(pcoord->y);
const auto cursorWidth = _pData->IsCursorDoubleWidth() ? 2 : 1;
const til::inclusive_rect cursorRect = { pcoord->x, pcoord->y, pcoord->x + cursorWidth - 1, pcoord->y };
auto cursorView = Viewport::FromInclusive(BufferToScreenLine(cursorRect, lineRendition));
til::inclusive_rect cursorRect = { pcoord->x, pcoord->y, pcoord->x + cursorWidth - 1, pcoord->y };
cursorRect = BufferToScreenLine(cursorRect, lineRendition);

// The region is clamped within the viewport boundaries and we only
// trigger a redraw if the region is not empty.
// That region is then clipped within the viewport boundaries and we
// only trigger a redraw if the resulting region is not empty.
auto view = _pData->GetViewport();
if (view.IsInBounds(cursorView))
auto updateRect = til::rect{ cursorRect };
if (view.TrimToViewport(&updateRect))
{
const auto updateRect = view.ConvertToOrigin(cursorView).ToExclusive();
view.ConvertToOrigin(&updateRect);
FOREACH_ENGINE(pEngine)
{
LOG_IF_FAILED(pEngine->InvalidateCursor(&updateRect));
Expand Down