From 5a0783c38c98a4980b505bf942a909a649a60d83 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 17 Jun 2017 22:24:27 +0200 Subject: [PATCH 1/4] Send mouse events before touch event. It seems the order is important for Qt 5.9 --- interface/src/Application.cpp | 7 +++---- interface/src/Application.h | 2 +- interface/src/ui/overlays/Web3DOverlay.cpp | 14 ++++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5e168c6620..287ac2931e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -953,7 +953,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // Make sure we don't time out during slow operations at startup updateHeartbeat(); - connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); + connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit())); // hook up bandwidth estimator QSharedPointer bandwidthRecorder = DependencyManager::get(); @@ -1238,7 +1238,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); }); - connect(this, &Application::aboutToQuit, [=]() { + QObject::connect(this, &Application::aboutToQuit, [=]() { setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); }); @@ -1447,7 +1447,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); sendStatsTimer->start(); - // Periodically check for count of nearby avatars static int lastCountOfNearbyAvatars = -1; QTimer* checkNearbyAvatarsTimer = new QTimer(this); @@ -1642,7 +1641,7 @@ void Application::updateHeartbeat() const { static_cast(_deadlockWatchdogThread)->updateHeartbeat(); } -void Application::aboutToQuit() { +void Application::onAboutToQuit() { emit beforeAboutToQuit(); foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 46e5e882a4..bcb5e2bc10 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -401,7 +401,7 @@ private slots: void showDesktop(); void clearDomainOctreeDetails(); void clearDomainAvatars(); - void aboutToQuit(); + void onAboutToQuit(); void resettingDomain(); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index e26a641206..a688e90e69 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -441,17 +441,19 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { touchEvent->setTouchPoints(touchPoints); touchEvent->setTouchPointStates(touchPointState); + // Send mouse events to the Web surface so that HTML dialog elements work with mouse press and hover. + // FIXME: Scroll bar dragging is a bit unstable in the tablet (content can jump up and down at times). + // This may be improved in Qt 5.8. Release notes: "Cleaned up touch and mouse event delivery". + // + // In Qt 5.9 mouse events must be sent before touch events to make sure some QtQuick components will receive mouse events + QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); + QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); if (this->_pressed && event.getType() == PointerEvent::Move) { return; } - // Send mouse events to the Web surface so that HTML dialog elements work with mouse press and hover. - // FIXME: Scroll bar dragging is a bit unstable in the tablet (content can jump up and down at times). - // This may be improved in Qt 5.8. Release notes: "Cleaned up touch and mouse event delivery". - - QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); - QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); } void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { From a1475bc65f860d4b15a841665711c703647edfc7 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 17 Jun 2017 23:02:52 +0200 Subject: [PATCH 2/4] Forgot if statement --- interface/src/ui/overlays/Web3DOverlay.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 6d4de9e181..f9745bdf2f 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -444,15 +444,14 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { // FIXME: Scroll bar dragging is a bit unstable in the tablet (content can jump up and down at times). // This may be improved in Qt 5.8. Release notes: "Cleaned up touch and mouse event delivery". // - // In Qt 5.9 mouse events must be sent before touch events to make sure some QtQuick components will receive mouse events - QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); - QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); + // In Qt 5.9 mouse events must be sent before touch events to make sure some QtQuick components will + // receive mouse events + if (!(this->_pressed && event.getType() == PointerEvent::Move)) { + QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); + } QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); - - if (this->_pressed && event.getType() == PointerEvent::Move) { - return; - } } void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { From f34faa3ee7e24c3d2dbe5116fc5d8fb61e53ac21 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sun, 18 Jun 2017 10:54:59 +0200 Subject: [PATCH 3/4] Fix backward compatibility with Qt 5.6 --- interface/src/ui/overlays/Web3DOverlay.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index f9745bdf2f..f9ec60c267 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -446,12 +446,21 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { // // In Qt 5.9 mouse events must be sent before touch events to make sure some QtQuick components will // receive mouse events +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) if (!(this->_pressed && event.getType() == PointerEvent::Move)) { QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); } - +#endif QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); + +#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) + if (this->_pressed && event.getType() == PointerEvent::Move) { + return; + } + QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); +#endif } void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { From 59a77c16bd5072d6c10d00302ef66d95a23577c5 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sun, 18 Jun 2017 20:59:22 +0200 Subject: [PATCH 4/4] Cleanup --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 65f15af550..71c4657264 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1240,7 +1240,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); }); - QObject::connect(this, &Application::aboutToQuit, [=]() { + connect(this, &Application::aboutToQuit, [=]() { setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); setKeyboardFocusEntity(UNKNOWN_ENTITY_ID); });