on xenial help sign in
don't emit pushStopped() unnecessarily if not pushing
commit52a6b8caed504541aa0b0395cfb788242fe45c7a authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 1 Sep 2016, 10:36 (10 years ago) parent7d1ad5f
2 files changed+12−1
plugins/Cursor/MousePointer.cpp+11−1 plugins/Cursor/MousePointer.h+1
plugins/Cursor/MousePointer.cpp+11−1
@@ -58,23 +58,33 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
5858 if (newX <= 0 && newY < m_topBoundaryOffset) { // top left corner
5959 const auto distance = qSqrt(qPow(newX, 2) + qPow(newY-m_topBoundaryOffset, 2));
6060 Q_EMIT pushedTopLeftCorner(qAbs(distance), buttons);
61+ m_pushing = true;
6162 } else if (newX >= sceneWidth-1 && newY < m_topBoundaryOffset) { // top right corner
6263 const auto distance = qSqrt(qPow(newX-sceneWidth, 2) + qPow(newY-m_topBoundaryOffset, 2));
6364 Q_EMIT pushedTopRightCorner(qAbs(distance), buttons);
65+ m_pushing = true;
6466 } else if (newX < 0 && newY >= sceneHeight-1) { // bottom left corner
6567 const auto distance = qSqrt(qPow(newX, 2) + qPow(newY-sceneHeight, 2));
6668 Q_EMIT pushedBottomLeftCorner(qAbs(distance), buttons);
69+ m_pushing = true;
6770 } else if (newX >= sceneWidth-1 && newY >= sceneHeight-1) { // bottom right corner
6871 const auto distance = qSqrt(qPow(newX-sceneWidth, 2) + qPow(newY-sceneHeight, 2));
6972 Q_EMIT pushedBottomRightCorner(qAbs(distance), buttons);
73+ m_pushing = true;
7074 } else if (newX < 0) { // left edge
7175 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
76+ m_pushing = true;
7277 } else if (newX >= sceneWidth) { // right edge
7378 Q_EMIT pushedRightBoundary(newX - (sceneWidth - 1), buttons);
79+ m_pushing = true;
7480 } else if (newY < m_topBoundaryOffset) { // top edge
7581 Q_EMIT pushedTopBoundary(qAbs(newY - m_topBoundaryOffset), buttons);
82+ m_pushing = true;
7683 } else if (Q_LIKELY(newX > 0 && newX < sceneWidth-1 && newY > 0 && newY < sceneHeight-1)) { // normal pos, not pushing
77− Q_EMIT pushStopped();
84+ if (m_pushing) {
85+ Q_EMIT pushStopped();
86+ m_pushing = false;
87+ }
7888 }
7989
8090 setX(qBound(0.0, newX, sceneWidth - 1));
plugins/Cursor/MousePointer.h+1
@@ -79,6 +79,7 @@ private:
7979 QPointF m_accumulatedMovement;
8080
8181 int m_topBoundaryOffset{0};
82+ bool m_pushing{false};
8283};
8384
8485#endif // MOUSEPOINTER_H