Solve Jitteriness while scrolling.

This commit is contained in:
volansystech 2017-05-25 17:28:19 +05:30
parent aab80629ea
commit cab6f3f7c3

View file

@ -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);
}