mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-15 17:46:47 +02:00
Solve Jitteriness while scrolling.
This commit is contained in:
parent
aab80629ea
commit
cab6f3f7c3
1 changed files with 15 additions and 5 deletions
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue