diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2021-01-09 00:30:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-09 00:30:16 +0100 |
commit | 5df7bc495f794ff02775310bacc592c4ba004a32 (patch) | |
tree | 3496087b6fb9d098d0b99c163d9a699be2d97336 /src/widget | |
parent | a1cc267f91826830ee4e1cab8318a44641e445e2 (diff) | |
parent | d5356e3d12d8d1ccd254be784cef1694f0c656e8 (diff) |
Merge pull request #3512 from Swiftb0y/fix_knob_touchscreen_interaction
Fix broken knob interaction on touchscreens
Diffstat (limited to 'src/widget')
-rw-r--r-- | src/widget/knobeventhandler.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widget/knobeventhandler.h b/src/widget/knobeventhandler.h index f06fbc26ce..5ab63c85df 100644 --- a/src/widget/knobeventhandler.h +++ b/src/widget/knobeventhandler.h @@ -22,13 +22,13 @@ class KnobEventHandler { double valueFromMouseEvent(T* pWidget, QMouseEvent* e) { QPoint cur(e->globalPos()); - QPoint diff(cur - m_startPos); + QPoint diff(cur - m_prevPos); double dist = sqrt(static_cast<double>(diff.x() * diff.x() + diff.y() * diff.y())); bool y_dominant = abs(diff.y()) > abs(diff.x()); - // if y is dominant, then thread an increase in dy as negative (y is + // if y is dominant, then treat an increase in dy as negative (y is // pointed downward). Otherwise, if y is not dominant and x has - // decreased, then thread it as negative. + // decreased, then treat it as negative. if ((y_dominant && diff.y() > 0) || (!y_dominant && diff.x() < 0)) { dist = -dist; } @@ -44,10 +44,10 @@ class KnobEventHandler { void mouseMoveEvent(T* pWidget, QMouseEvent* e) { if (!m_bRightButtonPressed) { - QCursor::setPos(m_startPos); double value = valueFromMouseEvent(pWidget, e); pWidget->setControlParameterDown(value); pWidget->inputActivity(); + m_prevPos = e->globalPos(); } } @@ -60,6 +60,7 @@ class KnobEventHandler { case Qt::LeftButton: case Qt::MiddleButton: m_startPos = e->globalPos(); + m_prevPos = m_startPos; // Somehow using Qt::BlankCursor does not work on Windows // https://mixxx.org/forums/viewtopic.php?p=40298#p40298 QApplication::setOverrideCursor(m_blankCursor); @@ -107,5 +108,6 @@ class KnobEventHandler { // Starting point when left mouse button is pressed QPoint m_startPos; + QPoint m_prevPos; QCursor m_blankCursor; }; |