From e03d6f8cf27385c473bbc50eac5991af4ae99655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Oct 2020 08:20:30 +0200 Subject: make use of toBool() --- src/mixxxapplication.cpp | 2 +- src/widget/wwidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 2b31c3df7d..8533ced812 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -212,5 +212,5 @@ bool MixxxApplication::touchIsRightButton() { m_pTouchShift = new ControlProxy( "[Controls]", "touch_shift", this); } - return (m_pTouchShift->get() != 0.0); + return (m_pTouchShift->toBool()); } diff --git a/src/widget/wwidget.cpp b/src/widget/wwidget.cpp index 4bbd4679ce..4bee1cecec 100644 --- a/src/widget/wwidget.cpp +++ b/src/widget/wwidget.cpp @@ -38,7 +38,7 @@ WWidget::~WWidget() { } bool WWidget::touchIsRightButton() { - return (m_pTouchShift->get() != 0.0); + return (m_pTouchShift->toBool()); } bool WWidget::event(QEvent* e) { -- cgit v1.2.3 From f607ce820d51fdf8ad682a4809d417bc7fcae102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Oct 2020 23:08:24 +0200 Subject: Make use of QT's MouseEvent Synthesizer but modify the mouse button according to "touch_shift" --- src/mixxx.cpp | 21 -------------------- src/mixxx.h | 5 ++--- src/mixxxapplication.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++---- src/mixxxapplication.h | 6 +++--- 4 files changed, 52 insertions(+), 31 deletions(-) diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 19610fcfbd..515e1f5c66 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -219,7 +219,6 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { pConfig->getValue(ConfigKey("[Controls]", "Tooltips"), static_cast(mixxx::TooltipsPreference::TOOLTIPS_ON))); - setAttribute(Qt::WA_AcceptTouchEvents); m_pTouchShift = new ControlPushButton(ConfigKey("[Controls]", "touch_shift")); m_pChannelHandleFactory = new ChannelHandleFactory(); @@ -1365,26 +1364,6 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) { return QObject::eventFilter(obj, event); } -bool MixxxMainWindow::event(QEvent* e) { - switch(e->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - { - // If the touch event falls through to the main widget, no touch widget - // was touched, so we resend it as a mouse event. - // We have to accept it here, so QApplication will continue to deliver - // the following events of this touch point as well. - QTouchEvent* touchEvent = static_cast(e); - touchEvent->accept(); - return true; - } - default: - break; - } - return QWidget::event(e); -} - void MixxxMainWindow::closeEvent(QCloseEvent *event) { // WARNING: We can receive a CloseEvent while only partially // initialized. This is because we call QApplication::processEvents to diff --git a/src/mixxx.h b/src/mixxx.h index 4559890144..842655f26f 100644 --- a/src/mixxx.h +++ b/src/mixxx.h @@ -110,9 +110,8 @@ class MixxxMainWindow : public QMainWindow { protected: // Event filter to block certain events (eg. tooltips if tooltips are disabled) - virtual bool eventFilter(QObject *obj, QEvent *event); - virtual void closeEvent(QCloseEvent *event); - virtual bool event(QEvent* e); + bool eventFilter(QObject *obj, QEvent *event) override; + void closeEvent(QCloseEvent *event) override; private: void initialize(QApplication *app, const CmdlineArgs& args); diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 8533ced812..0425fc303b 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -41,13 +41,23 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets) #endif #endif +namespace { + +class QMouseEventEditable : public QMouseEvent { + public: + // Inherit constructors from base class + using QMouseEvent::QMouseEvent; + void setButton(Qt::MouseButton button) { + b = button; + } +}; + +} // anonymous namespace MixxxApplication::MixxxApplication(int& argc, char** argv) : QApplication(argc, argv), - m_fakeMouseSourcePointId(0), - m_fakeMouseWidget(NULL), - m_activeTouchButton(Qt::NoButton), - m_pTouchShift(NULL) { + m_rightPessedButtons(0), + m_pTouchShift(nullptr) { registerMetaTypes(); } @@ -207,6 +217,39 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { #endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #endif // Q_OS_MAC +bool MixxxApplication::notify(QObject* target, QEvent* event) { + // All touch events are translated in two simultaneous events one for + // target QWidgetWindow and one for the target QWidget + // A second touch becomes a mouse move without additional press and release + // events + switch (event->type()) { + case QEvent::MouseButtonPress: { + QMouseEventEditable* mouseEvent = static_cast(event); + if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && + mouseEvent->button() == Qt::LeftButton && + touchIsRightButton()) { + mouseEvent->setButton(Qt::RightButton); + m_rightPessedButtons++; + DEBUG_ASSERT(m_rightPessedButtons <= 2); + } + break; + } + case QEvent::MouseButtonRelease: { + QMouseEventEditable* mouseEvent = static_cast(event); + if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && + mouseEvent->button() == Qt::LeftButton && + m_rightPessedButtons > 0) { + mouseEvent->setButton(Qt::RightButton); + m_rightPessedButtons--; + } + break; + } + default: + break; + } + return QApplication::notify(target, event); +} + bool MixxxApplication::touchIsRightButton() { if (!m_pTouchShift) { m_pTouchShift = new ControlProxy( diff --git a/src/mixxxapplication.h b/src/mixxxapplication.h index b512f68a8c..6120020457 100644 --- a/src/mixxxapplication.h +++ b/src/mixxxapplication.h @@ -17,13 +17,13 @@ class MixxxApplication : public QApplication { #endif #endif + bool notify(QObject*, QEvent*) override; + private: bool touchIsRightButton(); void registerMetaTypes(); - int m_fakeMouseSourcePointId; - QWidget* m_fakeMouseWidget; - enum Qt::MouseButton m_activeTouchButton; + int m_rightPessedButtons; ControlProxy* m_pTouchShift; }; -- cgit v1.2.3 From 1ef74d9215055c42e3e9776aad2f865bd1a4b1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 8 Oct 2020 23:25:27 +0200 Subject: Update CHANGELOG --- CHANGELOG | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5552179036..a1ae997395 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,9 @@ * Add controller mapping for Hercules DJControl Jogvision #2370 * Fix missing manual in deb package lp:1889776 * Fix caching of duplicate tracks that reference the same file #3027 -* Fix loss of precision when dealing with floating-point sample positions while setting loop out position and seeking using vinyl control #3126 #3127 +* Fix loss of precision when dealing with floating-point sample positions + while setting loop out position and seeking using vinyl control #3126 #3127 +* Fix touch control lp:1895431 ==== 2.2.4 2020-05-10 ==== -- cgit v1.2.3 From 0139cbacaa099e56e59748ccf9382ce3c6c7f074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 14 Oct 2020 10:19:24 +0200 Subject: Remove redundant parentheses --- src/mixxxapplication.cpp | 2 +- src/widget/wwidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 0425fc303b..84bc4514de 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -255,5 +255,5 @@ bool MixxxApplication::touchIsRightButton() { m_pTouchShift = new ControlProxy( "[Controls]", "touch_shift", this); } - return (m_pTouchShift->toBool()); + return m_pTouchShift->toBool(); } diff --git a/src/widget/wwidget.cpp b/src/widget/wwidget.cpp index 4bee1cecec..365e2965a1 100644 --- a/src/widget/wwidget.cpp +++ b/src/widget/wwidget.cpp @@ -38,7 +38,7 @@ WWidget::~WWidget() { } bool WWidget::touchIsRightButton() { - return (m_pTouchShift->toBool()); + return m_pTouchShift->toBool(); } bool WWidget::event(QEvent* e) { -- cgit v1.2.3 From 9e7c957f6f7f379b98c2b598466815acd8ef97cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 14 Oct 2020 10:29:52 +0200 Subject: Improve comments and only allow one right click at a time. --- src/mixxxapplication.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 84bc4514de..c50726de50 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -228,9 +228,13 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && mouseEvent->button() == Qt::LeftButton && touchIsRightButton()) { + // Assert the assumption that QT synthesizes only one click at a time + // = two events (see above) + VERIFY_OR_DEBUG_ASSERT(m_rightPessedButtons < 2) { + break; + } mouseEvent->setButton(Qt::RightButton); m_rightPessedButtons++; - DEBUG_ASSERT(m_rightPessedButtons <= 2); } break; } -- cgit v1.2.3 From 73db83fba6552a59b248811d5f3f97cab3b970f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 14 Oct 2020 10:37:29 +0200 Subject: Removed constructor and added comments to the QMouseEventEditable class --- src/mixxxapplication.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index c50726de50..24dd27e65c 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -43,10 +43,11 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets) namespace { +/// This class allows to change the button of a mouse event on the fly. +/// This is required because we want to change the behaviour of Qts mouse +/// buttony synthesizer without duplicate all the code. class QMouseEventEditable : public QMouseEvent { public: - // Inherit constructors from base class - using QMouseEvent::QMouseEvent; void setButton(Qt::MouseButton button) { b = button; } -- cgit v1.2.3 From d76c5f98d65db12a7ac355d3f941d6bb359e0efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 23 Oct 2020 10:00:26 +0200 Subject: Move to Xenial since Trusty has been abdoned --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bed9ac3001..3d34516400 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: c++ matrix: include: - os: linux - dist: trusty + dist: xenial sudo: required compiler: gcc @@ -37,7 +37,7 @@ addons: - libtag1-dev - libupower-glib-dev - libusb-1.0-0-dev - - libvamp-hostsdk3 + - libvamp-hostsdk3v5 - libwavpack-dev - portaudio19-dev - protobuf-compiler @@ -65,7 +65,7 @@ install: - export COMMON="-j4 qt5=1 test=1 mad=1 faad=1 ffmpeg=1 opus=1 modplug=1 wv=1 hss1394=0 virtualize=0 debug_assertions_fatal=1 verbose=0" ##### - # Ubuntu Trusty Build + # Ubuntu Xenial Build #### # OS X Build -- cgit v1.2.3 From 8432b36bc22e06a2dc892ea850a32ff262d1c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 27 Oct 2020 20:33:16 +0100 Subject: Fix typo --- src/mixxxapplication.cpp | 10 +++++----- src/mixxxapplication.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 24dd27e65c..1ee2ee7602 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -57,7 +57,7 @@ class QMouseEventEditable : public QMouseEvent { MixxxApplication::MixxxApplication(int& argc, char** argv) : QApplication(argc, argv), - m_rightPessedButtons(0), + m_rightPressedButtons(0), m_pTouchShift(nullptr) { registerMetaTypes(); } @@ -231,11 +231,11 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { touchIsRightButton()) { // Assert the assumption that QT synthesizes only one click at a time // = two events (see above) - VERIFY_OR_DEBUG_ASSERT(m_rightPessedButtons < 2) { + VERIFY_OR_DEBUG_ASSERT(m_rightPressedButtons < 2) { break; } mouseEvent->setButton(Qt::RightButton); - m_rightPessedButtons++; + m_rightPressedButtons++; } break; } @@ -243,9 +243,9 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { QMouseEventEditable* mouseEvent = static_cast(event); if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && mouseEvent->button() == Qt::LeftButton && - m_rightPessedButtons > 0) { + m_rightPressedButtons > 0) { mouseEvent->setButton(Qt::RightButton); - m_rightPessedButtons--; + m_rightPressedButtons--; } break; } diff --git a/src/mixxxapplication.h b/src/mixxxapplication.h index 6120020457..f0dfc94ce2 100644 --- a/src/mixxxapplication.h +++ b/src/mixxxapplication.h @@ -23,7 +23,7 @@ class MixxxApplication : public QApplication { bool touchIsRightButton(); void registerMetaTypes(); - int m_rightPessedButtons; + int m_rightPressedButtons; ControlProxy* m_pTouchShift; }; -- cgit v1.2.3 From bb57e8cecf062d213533607a6488952db4584aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 27 Oct 2020 20:35:05 +0100 Subject: Update comments Co-authored-by: Be --- src/mixxxapplication.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 1ee2ee7602..2b52033391 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -219,10 +219,10 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { #endif // Q_OS_MAC bool MixxxApplication::notify(QObject* target, QEvent* event) { - // All touch events are translated in two simultaneous events one for - // target QWidgetWindow and one for the target QWidget + // All touch events are translated into two simultaneous events: one for + // the target QWidgetWindow and one for the target QWidget. // A second touch becomes a mouse move without additional press and release - // events + // events. switch (event->type()) { case QEvent::MouseButtonPress: { QMouseEventEditable* mouseEvent = static_cast(event); -- cgit v1.2.3 From e70ea15e7fae0a5e9df18846d0739b1592ca8dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 28 Oct 2020 20:36:17 +0100 Subject: Set the source of the Syntesized QMouseEvent --- src/widget/wwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/widget/wwidget.cpp b/src/widget/wwidget.cpp index 365e2965a1..6f29abe758 100644 --- a/src/widget/wwidget.cpp +++ b/src/widget/wwidget.cpp @@ -91,11 +91,13 @@ bool WWidget::event(QEvent* e) { const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first(); QMouseEvent mouseEvent(eventType, - touchPoint.pos().toPoint(), - touchPoint.screenPos().toPoint(), + touchPoint.pos(), + touchPoint.pos(), + touchPoint.screenPos(), m_activeTouchButton, // Button that causes the event Qt::NoButton, // Not used, so no need to fake a proper value. - touchEvent->modifiers()); + touchEvent->modifiers(), + Qt::MouseEventSynthesizedByApplication); return QWidget::event(&mouseEvent); } -- cgit v1.2.3