diff --git a/src/plugins/shakecursor/shakedetector.cpp b/src/plugins/shakecursor/shakedetector.cpp index 0f4e69264f..5b8f5a8fc2 100644 --- a/src/plugins/shakecursor/shakedetector.cpp +++ b/src/plugins/shakecursor/shakedetector.cpp @@ -45,7 +45,7 @@ std::optional ShakeDetector::update(QMouseEvent *event) m_history.erase(m_history.begin(), it); } - m_history.append(HistoryItem{ + m_history.emplace_back(HistoryItem{ .position = event->localPos(), .timestamp = event->timestamp(), }); @@ -56,7 +56,7 @@ std::optional ShakeDetector::update(QMouseEvent *event) qreal bottom = m_history[0].position.y(); qreal distance = 0; - for (int i = 1; i < m_history.size(); ++i) { + for (size_t i = 1; i < m_history.size(); ++i) { // Compute the length of the mouse path. const qreal deltaX = m_history.at(i).position.x() - m_history.at(i - 1).position.x(); const qreal deltaY = m_history.at(i).position.y() - m_history.at(i - 1).position.y(); diff --git a/src/plugins/shakecursor/shakedetector.h b/src/plugins/shakecursor/shakedetector.h index 305fdb2dab..51c2898522 100644 --- a/src/plugins/shakecursor/shakedetector.h +++ b/src/plugins/shakecursor/shakedetector.h @@ -8,6 +8,7 @@ #include +#include #include /** @@ -37,7 +38,7 @@ private: quint64 timestamp; }; - QList m_history; + std::deque m_history; quint64 m_interval = 1000; qreal m_sensitivity = 4; };