on xenial help sign in
Don't let the mouse go outside the parentItem (LP: #1525350)
commit2bf24db8bf834403433ed445895f6213c177e752 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 27 Jun 2016, 18:43 (10 years ago) parenta53d87596d86ac
1 file changed+5−5
plugins/Cursor/MousePointer.cpp+5−5
plugins/Cursor/MousePointer.cpp+5−5
@@ -52,17 +52,17 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
5252 if (newX < 0) {
5353 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
5454 newX = 0;
55− } else if (newX > parentItem()->width()) {
56− Q_EMIT pushedRightBoundary(newX - parentItem()->width(), buttons);
57− newX = parentItem()->width();
55+ } else if (newX >= parentItem()->width()) {
56+ Q_EMIT pushedRightBoundary(newX - (parentItem()->width() - 1), buttons);
57+ newX = parentItem()->width() - 1;
5858 }
5959 setX(newX);
6060
6161 qreal newY = y() + appliedMovement.y();
6262 if (newY < 0) {
6363 newY = 0;
64− } else if (newY > parentItem()->height()) {
65− newY = parentItem()->height();
64+ } else if (newY >= parentItem()->height()) {
65+ newY = parentItem()->height() - 1;
6666 }
6767 setY(newY);
6868