forked from qt-creator/qt-creator
Terminal: Fix cursor/viewport updates
Under some font sizes the cursor size and cell size were not correctly aligned on the pixel grid, leaving behind artifacts of prior draws. Change-Id: I25e6efdc44102f24672912e1e56c31be0c686b89 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -920,9 +920,13 @@ void TerminalWidget::paintCursor(QPainter &p) const
|
||||
QRectF cursorRect = QRectF(gridToGlobal(cursor.position),
|
||||
gridToGlobal({cursor.position.x() + cursorCellWidth,
|
||||
cursor.position.y()},
|
||||
true));
|
||||
true))
|
||||
.toAlignedRect();
|
||||
|
||||
cursorRect.adjust(0, 0, 0, -1);
|
||||
cursorRect.adjust(1, 1, -1, -1);
|
||||
|
||||
QPen pen(Qt::white, 0, Qt::SolidLine);
|
||||
p.setPen(pen);
|
||||
|
||||
if (hasFocus()) {
|
||||
QPainter::CompositionMode oldMode = p.compositionMode();
|
||||
@@ -1162,14 +1166,14 @@ QRect TerminalWidget::gridToViewport(QRect rect) const
|
||||
int numRows = rect.height();
|
||||
int numCols = rect.width();
|
||||
|
||||
QRect r{qFloor(rect.x() * m_cellSize.width()),
|
||||
qFloor(startRow * m_cellSize.height()),
|
||||
qCeil(numCols * m_cellSize.width()),
|
||||
qCeil(numRows * m_cellSize.height())};
|
||||
QRectF r{rect.x() * m_cellSize.width(),
|
||||
startRow * m_cellSize.height(),
|
||||
numCols * m_cellSize.width(),
|
||||
numRows * m_cellSize.height()};
|
||||
|
||||
r.translate(0, topMargin());
|
||||
|
||||
return r;
|
||||
return r.toAlignedRect();
|
||||
}
|
||||
|
||||
void TerminalWidget::updateViewport()
|
||||
|
||||
Reference in New Issue
Block a user