diff options
author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-05-25 08:55:52 (GMT) |
---|---|---|
committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-05-25 09:31:31 (GMT) |
commit | e38aaf9f7c91efb6197f7f579e3064e0e6dcce1e (patch) | |
tree | 10097962202c9f950887ec071848950254e2ffd5 /src/gui | |
parent | 4c0ba0242ab70506dbd9a8b1dbf32bf7e670ed85 (diff) | |
download | Qt-e38aaf9f7c91efb6197f7f579e3064e0e6dcce1e.zip Qt-e38aaf9f7c91efb6197f7f579e3064e0e6dcce1e.tar.gz Qt-e38aaf9f7c91efb6197f7f579e3064e0e6dcce1e.tar.bz2 |
Fix cursor position test on CursorOnCharacter case
Reviewed-by: TrustMe
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 5 | ||||
-rw-r--r-- | src/gui/text/qtextengine_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 62de1fe..69598cf 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2716,7 +2716,8 @@ int QTextEngine::getClusterLength(unsigned short *logClusters, } int QTextEngine::positionInLigature(const QScriptItem *si, int end, - QFixed x, QFixed edge, int glyph_pos) + QFixed x, QFixed edge, int glyph_pos, + bool cursorOnCharacter) { unsigned short *logClusters = this->logClusters(si); int clusterStart = -1; @@ -2754,6 +2755,8 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end, int n = ((x - left) / perItemWidth).floor().toInt(); QFixed dist = x - left - n * perItemWidth; int closestItem = dist > (perItemWidth / 2) ? n + 1 : n; + if (cursorOnCharacter && closestItem > 0) + closestItem--; int pos = si->position + clusterStart + closestItem; // Jump to the next charStop while (!attrs[pos].charStop && pos < end) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index f8939e3..09610ff 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -594,7 +594,7 @@ public: void shapeLine(const QScriptLine &line); QFixed leadingSpaceWidth(const QScriptLine &line); - int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos); + int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter); private: void setBoundary(int strPos) const; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a9179ed..4b3c9e7 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2677,10 +2677,12 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const } } if (qAbs(x-pos) < dist) - return eng->positionInLigature(&si, end, x, pos, -1); + return eng->positionInLigature(&si, end, x, pos, -1, + cpos == QTextLine::CursorOnCharacter); } Q_ASSERT(glyph_pos != -1); - return eng->positionInLigature(&si, end, x, edge, glyph_pos); + return eng->positionInLigature(&si, end, x, edge, glyph_pos, + cpos == QTextLine::CursorOnCharacter); } } // right of last item |