Workaround selection glitches on macOS.
This commit is contained in:
parent
d7e47aa8a6
commit
64fa3d83b5
1 changed files with 22 additions and 3 deletions
|
|
@ -1719,20 +1719,39 @@ private:
|
||||||
}
|
}
|
||||||
if (Q_UNLIKELY(hasSelected)) {
|
if (Q_UNLIKELY(hasSelected)) {
|
||||||
if (Q_UNLIKELY(hasNotSelected)) {
|
if (Q_UNLIKELY(hasNotSelected)) {
|
||||||
auto clippingEnabled = _p->hasClipping();
|
// There is a bug in retina QPainter clipping stack.
|
||||||
auto clippingRegion = _p->clipRegion();
|
// You can see glitches in rendering in such text:
|
||||||
|
// aA
|
||||||
|
// Aa
|
||||||
|
// Where selection is both 'A'-s.
|
||||||
|
// I can't debug it right now, this is a workaround.
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
_p->save();
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
const auto clippingEnabled = _p->hasClipping();
|
||||||
|
const auto clippingRegion = _p->clipRegion();
|
||||||
_p->setClipRect(selectedRect, Qt::IntersectClip);
|
_p->setClipRect(selectedRect, Qt::IntersectClip);
|
||||||
_p->setPen(*_currentPenSelected);
|
_p->setPen(*_currentPenSelected);
|
||||||
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
||||||
auto externalClipping = clippingEnabled ? clippingRegion : QRegion(QRect((_x - _w).toInt(), _y - _lineHeight, (_x + 2 * _w).toInt(), _y + 2 * _lineHeight));
|
const auto externalClipping = clippingEnabled
|
||||||
|
? clippingRegion
|
||||||
|
: QRegion(QRect(
|
||||||
|
(_x - _w).toInt(),
|
||||||
|
_y - _lineHeight,
|
||||||
|
(_x + 2 * _w).toInt(),
|
||||||
|
_y + 2 * _lineHeight));
|
||||||
_p->setClipRegion(externalClipping - selectedRect);
|
_p->setClipRegion(externalClipping - selectedRect);
|
||||||
_p->setPen(*_currentPen);
|
_p->setPen(*_currentPen);
|
||||||
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
_p->restore();
|
||||||
|
#else // Q_OS_MAC
|
||||||
if (clippingEnabled) {
|
if (clippingEnabled) {
|
||||||
_p->setClipRegion(clippingRegion);
|
_p->setClipRegion(clippingRegion);
|
||||||
} else {
|
} else {
|
||||||
_p->setClipping(false);
|
_p->setClipping(false);
|
||||||
}
|
}
|
||||||
|
#endif // Q_OS_MAC
|
||||||
} else {
|
} else {
|
||||||
_p->setPen(*_currentPenSelected);
|
_p->setPen(*_currentPenSelected);
|
||||||
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue