From 772e84b4c2326277d9a9b652a624ce30a2a9b109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 5 May 2022 17:40:44 +0200 Subject: [PATCH 1/3] Simplify the code around m_prevPos --- src/widget/knobeventhandler.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/knobeventhandler.h b/src/widget/knobeventhandler.h index 5ab63c85df9..9949748a973 100644 --- a/src/widget/knobeventhandler.h +++ b/src/widget/knobeventhandler.h @@ -21,8 +21,9 @@ class KnobEventHandler { } double valueFromMouseEvent(T* pWidget, QMouseEvent* e) { - QPoint cur(e->globalPos()); - QPoint diff(cur - m_prevPos); + QPoint cur = e->globalPos(); + QPoint diff = cur - m_prevPos; + m_prevPos = cur; double dist = sqrt(static_cast(diff.x() * diff.x() + diff.y() * diff.y())); bool y_dominant = abs(diff.y()) > abs(diff.x()); @@ -47,7 +48,6 @@ class KnobEventHandler { double value = valueFromMouseEvent(pWidget, e); pWidget->setControlParameterDown(value); pWidget->inputActivity(); - m_prevPos = e->globalPos(); } } From 87272cf0e8236acf72ecc238ff71639978df3979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 5 May 2022 17:52:45 +0200 Subject: [PATCH 2/3] Replace using to global cursor stack by using the widget cursor. This should be a workaround for the missing cursor, that happens on MacOS probably due to a missing release event in overload situations. lp196978 If this happens again, only one knob is affected instead of whole Mixxx and it heals itself by another mouse click because it is not longer stacking up. --- src/widget/knobeventhandler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widget/knobeventhandler.h b/src/widget/knobeventhandler.h index 9949748a973..348f4977005 100644 --- a/src/widget/knobeventhandler.h +++ b/src/widget/knobeventhandler.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -63,7 +62,7 @@ class KnobEventHandler { 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); + pWidget->setCursor(m_blankCursor); break; default: break; @@ -76,7 +75,7 @@ class KnobEventHandler { case Qt::LeftButton: case Qt::MiddleButton: QCursor::setPos(m_startPos); - QApplication::restoreOverrideCursor(); + pWidget->unsetCursor(); value = valueFromMouseEvent(pWidget, e); pWidget->setControlParameterUp(value); pWidget->inputActivity(); From 125d97def92fc4baee66bbf3d028ffaa8a885310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 5 May 2022 18:54:43 +0200 Subject: [PATCH 3/3] Use static functions for overriding curser via base class --- src/util/scopedoverridecursor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/scopedoverridecursor.h b/src/util/scopedoverridecursor.h index af08eb50d3d..1287cd0c17c 100644 --- a/src/util/scopedoverridecursor.h +++ b/src/util/scopedoverridecursor.h @@ -1,16 +1,16 @@ #pragma once -#include +#include class ScopedOverrideCursor { public: inline explicit ScopedOverrideCursor(const QCursor& cursor) { - QApplication::setOverrideCursor(cursor); - QApplication::processEvents(); + QGuiApplication::setOverrideCursor(cursor); + QCoreApplication::processEvents(); } inline virtual ~ScopedOverrideCursor() { - QApplication::restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); } };