From b2ac4381eb935e89eb907e523501f2330ae0a425 Mon Sep 17 00:00:00 2001 From: volansystech Date: Thu, 18 May 2017 19:13:59 +0530 Subject: [PATCH 1/4] Solve Jitteriness when scrolling the content in HMD mode -> Marketplace using the scrollbar. --- interface/src/ui/overlays/Web3DOverlay.cpp | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index d9eab9a78d..37dce9d6e4 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -427,29 +427,30 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { event.getButtons() == PointerEvent::SecondaryButton) { return; } + if (_inputMode == Touch) { + QTouchEvent::TouchPoint point; + point.setId(event.getID()); + point.setState(touchPointState); + point.setPos(windowPoint); + point.setScreenPos(windowPoint); + QList touchPoints; + touchPoints.push_back(point); - QTouchEvent::TouchPoint point; - point.setId(event.getID()); - point.setState(touchPointState); - point.setPos(windowPoint); - point.setScreenPos(windowPoint); - QList touchPoints; - touchPoints.push_back(point); + QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); + touchEvent->setWindow(_webSurface->getWindow()); + touchEvent->setTarget(_webSurface->getRootItem()); + touchEvent->setTouchPoints(touchPoints); + touchEvent->setTouchPointStates(touchPointState); - QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); - touchEvent->setWindow(_webSurface->getWindow()); - touchEvent->setTarget(_webSurface->getRootItem()); - touchEvent->setTouchPoints(touchPoints); - touchEvent->setTouchPointStates(touchPointState); + QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); + } else { + // 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". - QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); - - // 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); + QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); + } } void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { From 6da46c2d4c35350ada8a16a0c613e8513206bb06 Mon Sep 17 00:00:00 2001 From: volansystech Date: Sat, 20 May 2017 02:01:10 +0530 Subject: [PATCH 2/4] Resolve Mouse hover issue. --- interface/src/ui/overlays/Web3DOverlay.cpp | 52 ++++++++++------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 37dce9d6e4..8a06c0fdec 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -370,8 +370,7 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { QEvent::Type touchType; Qt::TouchPointState touchPointState; - QEvent::Type mouseType; - + Qt::MouseButton button = Qt::NoButton; Qt::MouseButtons buttons = Qt::NoButton; if (event.getButton() == PointerEvent::PrimaryButton) { @@ -385,18 +384,15 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { case PointerEvent::Press: touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; - mouseType = QEvent::MouseButtonPress; break; case PointerEvent::Release: touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; - mouseType = QEvent::MouseButtonRelease; break; case PointerEvent::Move: touchType = QEvent::TouchUpdate; touchPointState = Qt::TouchPointMoved; - mouseType = QEvent::MouseMove; - + if (((event.getButtons() & PointerEvent::PrimaryButton) > 0) != this->_pressed) { // Mouse was pressed/released while off the overlay; convert touch and mouse events to press/release to reflect // current mouse/touch status. @@ -404,12 +400,10 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (this->_pressed) { touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; - mouseType = QEvent::MouseButtonPress; } else { touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; - mouseType = QEvent::MouseButtonRelease; } button = Qt::LeftButton; @@ -427,30 +421,30 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { event.getButtons() == PointerEvent::SecondaryButton) { return; } - if (_inputMode == Touch) { - QTouchEvent::TouchPoint point; - point.setId(event.getID()); - point.setState(touchPointState); - point.setPos(windowPoint); - point.setScreenPos(windowPoint); - QList touchPoints; - touchPoints.push_back(point); + + QTouchEvent::TouchPoint point; + point.setId(event.getID()); + point.setState(touchPointState); + point.setPos(windowPoint); + point.setScreenPos(windowPoint); + QList touchPoints; + touchPoints.push_back(point); - QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); - touchEvent->setWindow(_webSurface->getWindow()); - touchEvent->setTarget(_webSurface->getRootItem()); - touchEvent->setTouchPoints(touchPoints); - touchEvent->setTouchPointStates(touchPointState); + QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); + touchEvent->setWindow(_webSurface->getWindow()); + touchEvent->setTarget(_webSurface->getRootItem()); + touchEvent->setTouchPoints(touchPoints); + touchEvent->setTouchPointStates(touchPointState); - QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); - } else { - // 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". + QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent, Qt::HighEventPriority); + + // 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); - } + QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseMove, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent, Qt::LowEventPriority); + } void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { From cab6f3f7c37aa7e07965564a4341187ef8345971 Mon Sep 17 00:00:00 2001 From: volansystech Date: Thu, 25 May 2017 17:28:19 +0530 Subject: [PATCH 3/4] Solve Jitteriness while scrolling. --- interface/src/ui/overlays/Web3DOverlay.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 8a06c0fdec..bfb5291170 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -370,7 +370,8 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { QEvent::Type touchType; Qt::TouchPointState touchPointState; - + QEvent::Type mouseType; + Qt::MouseButton button = Qt::NoButton; Qt::MouseButtons buttons = Qt::NoButton; if (event.getButton() == PointerEvent::PrimaryButton) { @@ -384,15 +385,18 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { case PointerEvent::Press: touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; + mouseType = QEvent::MouseButtonPress; break; case PointerEvent::Release: touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; + mouseType = QEvent::MouseButtonRelease; break; case PointerEvent::Move: touchType = QEvent::TouchUpdate; touchPointState = Qt::TouchPointMoved; - + mouseType = QEvent::MouseMove; + if (((event.getButtons() & PointerEvent::PrimaryButton) > 0) != this->_pressed) { // Mouse was pressed/released while off the overlay; convert touch and mouse events to press/release to reflect // current mouse/touch status. @@ -400,10 +404,12 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (this->_pressed) { touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; + mouseType = QEvent::MouseButtonPress; } else { touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; + mouseType = QEvent::MouseButtonRelease; } button = Qt::LeftButton; @@ -436,14 +442,18 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { touchEvent->setTouchPoints(touchPoints); touchEvent->setTouchPointStates(touchPointState); - QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent, Qt::HighEventPriority); + 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(QEvent::MouseMove, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); - QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent, Qt::LowEventPriority); + QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); + QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); } From 8d9cfbdf31a97aab13c46966be0657ae85be1aa3 Mon Sep 17 00:00:00 2001 From: volansystech Date: Fri, 26 May 2017 11:14:50 +0530 Subject: [PATCH 4/4] Resolve comments of @sethalves . Remove whitespaces. --- interface/src/ui/overlays/Web3DOverlay.cpp | 56 +++++++++++----------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index bfb5291170..75c793bf77 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -385,17 +385,17 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { case PointerEvent::Press: touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; - mouseType = QEvent::MouseButtonPress; + mouseType = QEvent::MouseButtonPress; break; case PointerEvent::Release: touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; - mouseType = QEvent::MouseButtonRelease; + mouseType = QEvent::MouseButtonRelease; break; case PointerEvent::Move: touchType = QEvent::TouchUpdate; touchPointState = Qt::TouchPointMoved; - mouseType = QEvent::MouseMove; + mouseType = QEvent::MouseMove; if (((event.getButtons() & PointerEvent::PrimaryButton) > 0) != this->_pressed) { // Mouse was pressed/released while off the overlay; convert touch and mouse events to press/release to reflect @@ -404,12 +404,12 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (this->_pressed) { touchType = QEvent::TouchBegin; touchPointState = Qt::TouchPointPressed; - mouseType = QEvent::MouseButtonPress; + mouseType = QEvent::MouseButtonPress; } else { touchType = QEvent::TouchEnd; touchPointState = Qt::TouchPointReleased; - mouseType = QEvent::MouseButtonRelease; + mouseType = QEvent::MouseButtonRelease; } button = Qt::LeftButton; @@ -427,34 +427,32 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { event.getButtons() == PointerEvent::SecondaryButton) { return; } - - QTouchEvent::TouchPoint point; - point.setId(event.getID()); - point.setState(touchPointState); - point.setPos(windowPoint); - point.setScreenPos(windowPoint); - QList touchPoints; - touchPoints.push_back(point); - QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); - touchEvent->setWindow(_webSurface->getWindow()); - touchEvent->setTarget(_webSurface->getRootItem()); - touchEvent->setTouchPoints(touchPoints); - touchEvent->setTouchPointStates(touchPointState); + QTouchEvent::TouchPoint point; + point.setId(event.getID()); + point.setState(touchPointState); + point.setPos(windowPoint); + point.setScreenPos(windowPoint); + QList touchPoints; + touchPoints.push_back(point); - QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); - - if (this->_pressed && event.getType() == PointerEvent::Move) { - return; - } + QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); + touchEvent->setWindow(_webSurface->getWindow()); + touchEvent->setTarget(_webSurface->getRootItem()); + 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". + QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); - QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); - QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); - + 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) {