aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugin/inputtypes.cpp7
-rw-r--r--tests/tst_cursornavigation.cpp5
2 files changed, 10 insertions, 2 deletions
diff --git a/plugin/inputtypes.cpp b/plugin/inputtypes.cpp
index c114ec8..60cd104 100644
--- a/plugin/inputtypes.cpp
+++ b/plugin/inputtypes.cpp
@@ -29,9 +29,12 @@ bool CursorNavigationCommand::angleIsBetween(qreal angle, qreal begin, qreal end
qreal CursorNavigationCommand::fitAngle(qreal angle)
{
+ if (angle >= 2.0*M_PI)
+ angle = std::fmod(angle, 2.0*M_PI);
+
if (angle > M_PI)
- return -M_PI + std::fmod(angle ,M_PI);
+ return -M_PI + std::fmod(angle, M_PI);
else if (angle < -M_PI)
- return M_PI + std::fmod(angle ,M_PI);
+ return M_PI + std::fmod(angle, M_PI);
return angle;
}
diff --git a/tests/tst_cursornavigation.cpp b/tests/tst_cursornavigation.cpp
index 5d842db..8891c4c 100644
--- a/tests/tst_cursornavigation.cpp
+++ b/tests/tst_cursornavigation.cpp
@@ -309,6 +309,11 @@ void TestCursorNavigation::test_navigation360()
QVERIFY(d0HasCursor.read().toBool());
QMetaObject::invokeMethod(centerAttached, "move", Q_ARG(qreal, 180), Q_ARG(qreal, 0));
QVERIFY(centerHasCursor.read().toBool());
+
+ QMetaObject::invokeMethod(centerAttached, "move", Q_ARG(qreal, 405), Q_ARG(qreal, 0));
+ QVERIFY(d45HasCursor.read().toBool());
+ QMetaObject::invokeMethod(centerAttached, "move", Q_ARG(qreal, -135), Q_ARG(qreal, 0));
+ QVERIFY(centerHasCursor.read().toBool());
}
void TestCursorNavigation::test_redirects()