mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Fixes related to cursor artifacts
This commit addresses some artifacts related to cursor updates. First issue is reported in #431171. It seems that an offset was intentionally left out when refreshing the cursor background. Second issue is related to resolved issue #483197: antialiasing when drawing is not properly working as reported in QTBUG-66036. Enabling antialiasing only for the outline should prevent artifacts while still rendering a proper outline. Other observed artifacts were fixed. BUG: 483197 BUG: 431171
This commit is contained in:
committed by
Christoph Cullmann
parent
94304ed698
commit
beb3aa5545
@@ -933,7 +933,7 @@ void TerminalDisplay::updateCursor()
|
||||
Q_ASSERT(cursorLocation < _imageSize);
|
||||
|
||||
int charWidth = _image[cursorLocation].width();
|
||||
QRect cursorRect = imageToWidget(QRect(_visualCursorPosition, QSize(charWidth, 1)));
|
||||
QRect cursorRect = imageToWidget(highdpi_adjust_rect(QRect(_visualCursorPosition, QSize(charWidth, 1))));
|
||||
update(cursorRect);
|
||||
}
|
||||
|
||||
|
||||
@@ -584,16 +584,13 @@ void TerminalPainter::updateCursorTextColor(const QColor &backgroundColor, QColo
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPainter::drawCursor(QPainter &painter, const QRect &rect, const QColor &foregroundColor, const QColor &backgroundColor, QColor &characterColor)
|
||||
void TerminalPainter::drawCursor(QPainter &painter, const QRectF &rect, const QColor &foregroundColor, const QColor &backgroundColor, QColor &characterColor)
|
||||
{
|
||||
if (m_parentDisplay->cursorBlinking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// shift rectangle top down one pixel to leave some space
|
||||
// between top and bottom
|
||||
// noticeable when linespace>1
|
||||
QRectF cursorRect = rect.adjusted(0, 1, 0, 0);
|
||||
const QRectF& cursorRect = rect;
|
||||
|
||||
QColor color = m_parentDisplay->terminalColor()->cursorColor();
|
||||
QColor cursorColor = color.isValid() ? color : foregroundColor;
|
||||
@@ -609,7 +606,6 @@ void TerminalPainter::drawCursor(QPainter &painter, const QRect &rect, const QCo
|
||||
painter.setPen(pen);
|
||||
|
||||
if (m_parentDisplay->cursorShape() == Enum::BlockCursor) {
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
if (m_parentDisplay->hasFocus()) {
|
||||
painter.fillRect(cursorRect, cursorColor);
|
||||
|
||||
@@ -617,9 +613,10 @@ void TerminalPainter::drawCursor(QPainter &painter, const QRect &rect, const QCo
|
||||
} else {
|
||||
// draw the cursor outline, adjusting the area so that
|
||||
// it is drawn entirely inside cursorRect
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.drawRect(cursorRect.adjusted(halfWidth, halfWidth, -halfWidth, -halfWidth));
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
}
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
} else if (m_parentDisplay->cursorShape() == Enum::UnderlineCursor) {
|
||||
QLineF line(cursorRect.left() + halfWidth, cursorRect.bottom() - halfWidth, cursorRect.right() - halfWidth, cursorRect.bottom() - halfWidth);
|
||||
painter.drawLine(line);
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
|
||||
void updateCursorTextColor(const QColor &backgroundColor, QColor &characterColor);
|
||||
// draws the cursor character
|
||||
void drawCursor(QPainter &painter, const QRect &rect, const QColor &foregroundColor, const QColor &backgroundColor, QColor &characterColor);
|
||||
void drawCursor(QPainter &painter, const QRectF &rect, const QColor &foregroundColor, const QColor &backgroundColor, QColor &characterColor);
|
||||
|
||||
TerminalDisplay *m_parentDisplay = nullptr;
|
||||
void drawBelowText(QPainter &painter,
|
||||
|
||||
Reference in New Issue
Block a user