Sophie

Sophie

distrib > Mageia > cauldron > x86_64 > media > core-release-src > by-pkgid > 4c532bfb9916518564da5ba2805999f5 > files > 126

qtbase5-5.15.12-3.mga10.src.rpm

From b2641e8090574adfa429bf92de397d81d88acbda Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Mon, 12 Jun 2023 22:51:51 +0200
Subject: [PATCH 128/147] Fix QTextEdit cursor rectangle vertical positioning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When there are characters with different pointsize in QScriptLine,
the value of si.descent is less than sl.descent, which will cause
the y value of the cursor rectangle to be too large.
If si.descent is less than sl.descent, the height of the cursor
rectangle is equal to base plus si.descent.
Amends e99a883bd382ca950192bd66cafb2a1de6394ce7

Fixes: QTBUG-96288
Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Pick-to: 6.1 6.2
Change-Id: I4a8566b32cfa75d8ca1a584f5e8e577c5c9caf0d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 33238ea2c63b372ee8795eaafbfc5a859a778f8d)

* asturmlechner 2023-06-12: Resolve conflict with kde/5.15 commit
  28b62aa315efd9408c7310331e45195ae4ed663d

Change-Id: I2c145a12610e57666097318216d4b51906b60e50
---
 src/gui/text/qtextlayout.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 845dd1ab2b..d13e1260e4 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1333,13 +1333,16 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
 
     QFixed base = sl.base();
     QFixed descent = sl.descent;
+    QFixed cursorDescent = descent;
     bool rightToLeft = d->isRightToLeft();
     if (itm >= 0) {
         const QScriptItem &si = d->layoutData->items.at(itm);
         if (si.ascent > 0)
             base = si.ascent;
-        if (si.descent > 0)
+        if (si.descent == 0)
             descent = si.descent;
+        else if (si.descent > 0 && si.descent < descent)
+            cursorDescent = si.descent;
         rightToLeft = si.analysis.bidiLevel % 2;
     }
     qreal y = position.y() + (sl.y + sl.base() - base).toReal();
@@ -1353,7 +1356,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
     const QTransform &deviceTransform = p->deviceTransform();
     const qreal xScale = deviceTransform.m11();
     if (deviceTransform.type() != QTransform::TxScale || std::trunc(xScale) == xScale) {
-        p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush());
+        p->fillRect(QRectF(x, y, qreal(width), (base + cursorDescent).toReal()), p->pen().brush());
     } else {
         // Ensure consistently rendered cursor width under fractional scaling
         const QPen origPen = p->pen();
@@ -1361,7 +1364,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
         pen.setCosmetic(true);
         const qreal center = x + qreal(width) / 2;
         p->setPen(pen);
-        p->drawLine(QPointF(center, y), QPointF(center, y + (base + descent).toReal()));
+        p->drawLine(QPointF(center, y), QPointF(center, y + (base + cursorDescent).toReal()));
         p->setPen(origPen);
     }
     p->setCompositionMode(origCompositionMode);
-- 
2.40.1