Resolve comments of @sethalves . Remove whitespaces.

This commit is contained in:
volansystech 2017-05-26 11:14:50 +05:30
parent cab6f3f7c3
commit 8d9cfbdf31

View file

@ -385,17 +385,17 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) {
case PointerEvent::Press: case PointerEvent::Press:
touchType = QEvent::TouchBegin; touchType = QEvent::TouchBegin;
touchPointState = Qt::TouchPointPressed; touchPointState = Qt::TouchPointPressed;
mouseType = QEvent::MouseButtonPress; mouseType = QEvent::MouseButtonPress;
break; break;
case PointerEvent::Release: case PointerEvent::Release:
touchType = QEvent::TouchEnd; touchType = QEvent::TouchEnd;
touchPointState = Qt::TouchPointReleased; touchPointState = Qt::TouchPointReleased;
mouseType = QEvent::MouseButtonRelease; mouseType = QEvent::MouseButtonRelease;
break; break;
case PointerEvent::Move: case PointerEvent::Move:
touchType = QEvent::TouchUpdate; touchType = QEvent::TouchUpdate;
touchPointState = Qt::TouchPointMoved; touchPointState = Qt::TouchPointMoved;
mouseType = QEvent::MouseMove; mouseType = QEvent::MouseMove;
if (((event.getButtons() & PointerEvent::PrimaryButton) > 0) != this->_pressed) { 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 // 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) { if (this->_pressed) {
touchType = QEvent::TouchBegin; touchType = QEvent::TouchBegin;
touchPointState = Qt::TouchPointPressed; touchPointState = Qt::TouchPointPressed;
mouseType = QEvent::MouseButtonPress; mouseType = QEvent::MouseButtonPress;
} else { } else {
touchType = QEvent::TouchEnd; touchType = QEvent::TouchEnd;
touchPointState = Qt::TouchPointReleased; touchPointState = Qt::TouchPointReleased;
mouseType = QEvent::MouseButtonRelease; mouseType = QEvent::MouseButtonRelease;
} }
button = Qt::LeftButton; button = Qt::LeftButton;
@ -427,34 +427,32 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) {
event.getButtons() == PointerEvent::SecondaryButton) { event.getButtons() == PointerEvent::SecondaryButton) {
return; return;
} }
QTouchEvent::TouchPoint point;
point.setId(event.getID());
point.setState(touchPointState);
point.setPos(windowPoint);
point.setScreenPos(windowPoint);
QList<QTouchEvent::TouchPoint> touchPoints;
touchPoints.push_back(point);
QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); QTouchEvent::TouchPoint point;
touchEvent->setWindow(_webSurface->getWindow()); point.setId(event.getID());
touchEvent->setTarget(_webSurface->getRootItem()); point.setState(touchPointState);
touchEvent->setTouchPoints(touchPoints); point.setPos(windowPoint);
touchEvent->setTouchPointStates(touchPointState); point.setScreenPos(windowPoint);
QList<QTouchEvent::TouchPoint> touchPoints;
touchPoints.push_back(point);
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); QTouchEvent* touchEvent = new QTouchEvent(touchType, &_touchDevice, event.getKeyboardModifiers());
touchEvent->setWindow(_webSurface->getWindow());
if (this->_pressed && event.getType() == PointerEvent::Move) { touchEvent->setTarget(_webSurface->getRootItem());
return; touchEvent->setTouchPoints(touchPoints);
} touchEvent->setTouchPointStates(touchPointState);
// Send mouse events to the Web surface so that HTML dialog elements work with mouse press and hover. QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
// 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); if (this->_pressed && event.getType() == PointerEvent::Move) {
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); 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) { void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) {