From c6d3bce7047dbcbe10a3a7c642f98ec28ae278a4 Mon Sep 17 00:00:00 2001 From: vladest Date: Sun, 10 Sep 2017 18:33:04 +0200 Subject: [PATCH 01/11] Switch off Flickable --- .../qml/controls/FlickableWebViewCore.qml | 77 +++++++++++++------ interface/src/main.cpp | 2 + interface/src/ui/overlays/Web3DOverlay.cpp | 8 +- scripts/system/edit.js | 1 + 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index 0460b5b16a..7d52db5034 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -14,25 +14,28 @@ Flickable { property alias webViewCore: _webview property alias webViewCoreProfile: _webview.profile + interactive: true property string userScriptUrl: "" property string urlTag: "noDownload=false"; signal newViewRequestedCallback(var request) signal loadingChangedCallback(var loadRequest) + property real previousHeight: height + boundsBehavior: Flickable.StopAtBounds StylesUIt.HifiConstants { id: hifi } - onHeightChanged: { - if (height > 0) { - //reload page since window dimentions changed, - //so web engine should recalculate page render dimentions - reloadTimer.start() - } - } +// onHeightChanged: { +// if (height > 0) { +// //reload page since window dimentions changed, +// //so web engine should recalculate page render dimentions +// reloadTimer.start() +// } +// } ScrollBar.vertical: ScrollBar { id: scrollBar @@ -48,8 +51,8 @@ Flickable { function onLoadingChanged(loadRequest) { if (WebEngineView.LoadStartedStatus === loadRequest.status) { - flick.contentWidth = flick.width - flick.contentHeight = flick.height +// flick.contentWidth = flick.width +// flick.contentHeight = flick.height // Required to support clicking on "hifi://" links var url = loadRequest.url.toString(); @@ -58,24 +61,47 @@ Flickable { _webview.stop(); } } + heightTimer.stop() } if (WebEngineView.LoadFailedStatus === loadRequest.status) { console.log(" Tablet WebEngineView failed to load url: " + loadRequest.url.toString()); + heightTimer.stop() } if (WebEngineView.LoadSucceededStatus === loadRequest.status) { //disable Chromium's scroll bars - _webview.runJavaScript("document.body.style.overflow = 'hidden';"); - //calculate page height - _webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) { - if (i_actualPageHeight !== undefined) { - flick.contentHeight = i_actualPageHeight - } else { - flick.contentHeight = flick.height; - } - }) - flick.contentWidth = flick.width +// _webview.runJavaScript("document.body.style.overflow = 'hidden';"); +// //calculate page height +// _webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) { +// if (i_actualPageHeight !== undefined) { +// flick.contentHeight = i_actualPageHeight +// } else { +// flick.contentHeight = flick.height; +// } +// }) +// previousHeight = flick.contentHeight +// flick.contentWidth = flick.width +// heightTimer.restart() + } + } + + Timer { + id: heightTimer + interval: 100 + repeat: true + onTriggered: { +// _webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) { +// if (i_actualPageHeight !== undefined) { +// var newheight = i_actualPageHeight +// if (newheight > 0 && newheight !== previousHeight) { +// previousHeight = newheight +// flick.contentHeight = previousHeight; +// _webview.height = newheight < flick.height ? newheight : flick.height +// console.log("new height", previousHeight) +// } +// } +// }) } } @@ -84,14 +110,15 @@ Flickable { interval: 100 repeat: false onTriggered: { - _webview.reload() + //_webview.reload() } } WebEngineView { id: _webview - height: parent.height + anchors.fill: parent + //height: parent.height profile: HFWebEngineProfile; @@ -139,10 +166,10 @@ Flickable { grantFeaturePermission(securityOrigin, feature, true); } - onContentsSizeChanged: { - flick.contentHeight = Math.max(contentsSize.height, flick.height); - flick.contentWidth = flick.width - } +// onContentsSizeChanged: { +// //flick.contentHeight = Math.max(contentsSize.height, flick.height); +// //flick.contentWidth = flick.width +// } //disable popup onContextMenuRequested: { request.accepted = true; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 503daa177d..b1373832ea 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -219,6 +219,8 @@ int main(int argc, const char* argv[]) { // Extend argv to enable WebGL rendering std::vector argvExtended(&argv[0], &argv[argc]); argvExtended.push_back("--ignore-gpu-blacklist"); + argvExtended.push_back("--enable-embedded-switches"); + argvExtended.push_back("--disable-overlay-scrollbar"); int argcExtended = (int)argvExtended.size(); Application app(argcExtended, const_cast(argvExtended.data()), startupTime, runningMarkerExisted); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 104082dee4..b50ac9d7cf 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -367,11 +367,11 @@ void Web3DOverlay::setProxyWindow(QWindow* proxyWindow) { } void Web3DOverlay::handlePointerEvent(const PointerEvent& event) { - if (_inputMode == Touch) { + //if (_inputMode == Touch) { handlePointerEventAsTouch(event); - } else { - handlePointerEventAsMouse(event); - } +// } else { +// handlePointerEventAsMouse(event); +// } } void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 8b61226235..1370b6109c 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1929,6 +1929,7 @@ var PropertiesTool = function (opts) { data.properties.keyLight.direction.y * DEGREES_TO_RADIANS ); } + print("data properties " + data.properties) Entities.editEntity(selectionManager.selections[0], data.properties); if (data.properties.name !== undefined || data.properties.modelURL !== undefined || data.properties.visible !== undefined || data.properties.locked !== undefined) { From e60bd1d6b36c5e0c3b27e8fb560797c1a2d905b1 Mon Sep 17 00:00:00 2001 From: vladest Date: Mon, 11 Sep 2017 19:14:43 +0200 Subject: [PATCH 02/11] SOme stupid experiments --- interface/CMakeLists.txt | 3 + interface/src/Application.cpp | 247 +++++++++++++++++++++ interface/src/Application.h | 20 ++ interface/src/ui/overlays/Web3DOverlay.cpp | 38 +++- 4 files changed, 303 insertions(+), 5 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 43e50c6d33..41c7a4d8a4 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -17,6 +17,9 @@ endforeach() find_package(Qt5LinguistTools REQUIRED) find_package(Qt5LinguistToolsMacros) +find_package(Qt5Gui) +include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + if (WIN32) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -bigobj") add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3650c495f2..956ace7a28 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -281,6 +281,34 @@ private: Q_LOGGING_CATEGORY(trace_app_input_mouse, "trace.app.input.mouse") +namespace utils { +inline bool isTouchEvent(const QEvent* event) +{ + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + return true; + default: + return false; + } +} + +inline bool isMouseEvent(const QEvent* event) +{ + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseMove: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonDblClick: + return true; + default: + return false; + } +} + +} + using namespace std; static QTimer locationUpdateTimer; @@ -3063,9 +3091,228 @@ bool Application::eventFilter(QObject* object, QEvent* event) { } } + // We try to be smart, if we received real touch event, we are probably on a device + // with touch screen, and we should not have touch mocking. + + if (!event->spontaneous() || m_realTouchEventReceived) + return false; + + if (utils::isTouchEvent(event)) { + if (m_pendingFakeTouchEventCount) + --m_pendingFakeTouchEventCount; + else + m_realTouchEventReceived = true; + return false; + } + + QQuickWindow* window = qobject_cast(object); + if (!window) { + return false; + } + + m_holdingControl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); + + if (event->type() == QEvent::KeyRelease && static_cast(event)->key() == Qt::Key_Control) { + foreach (int id, m_heldTouchPoints) + if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) { + m_touchPoints[id].setState(Qt::TouchPointReleased); + m_heldTouchPoints.remove(id); + } else + m_touchPoints[id].setState(Qt::TouchPointStationary); + sendTouchEvent(window, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast(event)->timestamp()); + } + + if (utils::isMouseEvent(event)) { + const QMouseEvent* const mouseEvent = static_cast(event); + + QTouchEvent::TouchPoint touchPoint; + touchPoint.setPressure(1); + + QEvent::Type touchType = QEvent::None; + + switch (mouseEvent->type()) { + case QEvent::MouseButtonPress: + touchPoint.setId(mouseEvent->button()); + if (m_touchPoints.contains(touchPoint.id())) { + touchPoint.setState(Qt::TouchPointMoved); + touchType = QEvent::TouchUpdate; + } else { + touchPoint.setState(Qt::TouchPointPressed); + // Check if more buttons are held down than just the event triggering one. + if (mouseEvent->buttons() > mouseEvent->button()) + touchType = QEvent::TouchUpdate; + else + touchType = QEvent::TouchBegin; + } + break; + case QEvent::MouseMove: + if (!mouseEvent->buttons()) { + // We have to swallow the event instead of propagating it, + // since we avoid sending the mouse release events and if the + // Flickable is the mouse grabber it would receive the event + // and would move the content. + event->accept(); + return true; + } + touchType = QEvent::TouchUpdate; + touchPoint.setId(mouseEvent->buttons()); + touchPoint.setState(Qt::TouchPointMoved); + break; + case QEvent::MouseButtonRelease: + // Check if any buttons are still held down after this event. + if (mouseEvent->buttons()) + touchType = QEvent::TouchUpdate; + else + touchType = QEvent::TouchEnd; + touchPoint.setId(mouseEvent->button()); + touchPoint.setState(Qt::TouchPointReleased); + break; + case QEvent::MouseButtonDblClick: + // Eat double-clicks, their accompanying press event is all we need. + event->accept(); + return true; + default: + Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type"); + } + + // A move can have resulted in multiple buttons, so we need check them individually. + if (touchPoint.id() & Qt::LeftButton) + updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton); + if (touchPoint.id() & Qt::MidButton) + updateTouchPoint(mouseEvent, touchPoint, Qt::MidButton); + if (touchPoint.id() & Qt::RightButton) + updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton); + + if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { + // We avoid sending the release event because the Flickable is + // listening to mouse events and would start a bounce-back + // animation if it received a mouse release. + event->accept(); + return true; + } + + // Update states for all other touch-points + for (QHash::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) { + if (!(it.value().id() & touchPoint.id())) + it.value().setState(Qt::TouchPointStationary); + } + + Q_ASSERT(touchType != QEvent::None); + + if (!sendTouchEvent(window, touchType, mouseEvent->timestamp())) + return false; + + event->accept(); + return true; + } + return false; } +static inline QRectF touchRectForPosition(QPointF centerPoint) { + QRectF touchRect(0, 0, 40, 40); + touchRect.moveCenter(centerPoint); + return touchRect; +} + +void Application::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton) +{ + // Ignore inserting additional touch points if Ctrl isn't held because it produces + // inconsistent touch events and results in assers in the gesture recognizers. + if (!m_holdingControl && m_touchPoints.size() && !m_touchPoints.contains(mouseButton)) + return; + + if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { + m_heldTouchPoints.insert(mouseButton); + return; + } + + // Gesture recognition uses the screen position for the initial threshold + // but since the canvas translates touch events we actually need to pass + // the screen position as the scene position to deliver the appropriate + // coordinates to the target. + touchPoint.setRect(touchRectForPosition(mouseEvent->localPos())); + touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos())); + + if (touchPoint.state() == Qt::TouchPointPressed) + touchPoint.setStartScenePos(mouseEvent->screenPos()); + else { + const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton]; + touchPoint.setStartScenePos(oldTouchPoint.startScenePos()); + touchPoint.setLastPos(oldTouchPoint.pos()); + touchPoint.setLastScenePos(oldTouchPoint.scenePos()); + } + + // Update current touch-point. + touchPoint.setId(mouseButton); + m_touchPoints.insert(mouseButton, touchPoint); +} + +bool Application::sendTouchEvent(QQuickWindow* window, QEvent::Type type, ulong timestamp) +{ + static QTouchDevice* device = 0; + if (!device) { + device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } + + m_pendingFakeTouchEventCount++; + + const QList& currentTouchPoints = m_touchPoints.values(); + Qt::TouchPointStates touchPointStates = 0; + foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) + touchPointStates |= touchPoint.state(); + + QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, currentTouchPoints); + event.setTimestamp(timestamp); + event.setAccepted(false); + + QGuiApplication::notify(window, &event); + + //updateVisualMockTouchPoints(window,m_holdingControl ? currentTouchPoints : QList()); + + // Get rid of touch-points that are no longer valid + foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) { + if (touchPoint.state() == Qt::TouchPointReleased) + m_touchPoints.remove(touchPoint.id()); + } + + return event.isAccepted(); +} + +//void Application::updateVisualMockTouchPoints(QQuickWindow* window, const QList& touchPoints) +//{ +// if (touchPoints.isEmpty()) { +// // Hide all touch indicator items. +// foreach (QQuickItem* item, m_activeMockComponents.values()) +// item->setProperty("pressed", false); + +// return; +// } + +// foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) { +// QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id()); + +// if (!mockTouchPointItem) { +// QQmlComponent touchMockPointComponent(window->engine(), QUrl("qrc:///qml/MockTouchPoint.qml")); +// mockTouchPointItem = qobject_cast(touchMockPointComponent.create()); +// Q_ASSERT(mockTouchPointItem); +// m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem); +// mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id())); +// mockTouchPointItem->setParent(window->rootObject()); +// mockTouchPointItem->setParentItem(window->rootObject()); +// } + +// QRectF touchRect = touchPoint.rect(); +// mockTouchPointItem->setX(touchRect.center().x()); +// mockTouchPointItem->setY(touchRect.center().y()); +// mockTouchPointItem->setWidth(touchRect.width()); +// mockTouchPointItem->setHeight(touchRect.height()); +// mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased)); +// } +//} + static bool _altPressed{ false }; void Application::keyPressEvent(QKeyEvent* event) { diff --git a/interface/src/Application.h b/interface/src/Application.h index c7f83ad28f..9be43c4d1d 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -516,6 +518,10 @@ private: void maybeToggleMenuVisible(QMouseEvent* event) const; void toggleTabletUI(bool shouldOpen = false) const; + void updateTouchPoint(const QMouseEvent *event, QTouchEvent::TouchPoint, Qt::MouseButton); + bool sendTouchEvent(QQuickWindow* window, QEvent::Type, ulong timestamp); + //void updateVisualMockTouchPoints(QQuickWindow *window,const QList &touchPoints); + MainWindow* _window; QElapsedTimer& _sessionRunTimer; @@ -705,6 +711,20 @@ private: RayPickManager _rayPickManager; LaserPointerManager _laserPointerManager; + //touch mocking + bool m_realTouchEventReceived { false }; + int m_pendingFakeTouchEventCount { 0 }; + + QPointF m_lastPos; + QPointF m_lastScreenPos; + QPointF m_startScreenPos; + + QHash m_touchPoints; + QSet m_heldTouchPoints; + QHash m_activeMockComponents; + + bool m_holdingControl { false }; + friend class RenderEventHandler; }; #endif // hifi_Application_h diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index b50ac9d7cf..f570d31bd6 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -67,7 +67,7 @@ Web3DOverlay::Web3DOverlay() : _dpi(DPI) { _touchDevice.setType(QTouchDevice::TouchScreen); _touchDevice.setName("RenderableWebEntityItemTouchDevice"); _touchDevice.setMaximumTouchPoints(4); - + QWindowSystemInterface::registerTouchDevice(&_touchDevice); _geometryId = DependencyManager::get()->allocateID(); connect(this, &Web3DOverlay::requestWebSurface, this, &Web3DOverlay::buildWebSurface); connect(this, &Web3DOverlay::releaseWebSurface, this, &Web3DOverlay::destroyWebSurface); @@ -367,11 +367,18 @@ void Web3DOverlay::setProxyWindow(QWindow* proxyWindow) { } void Web3DOverlay::handlePointerEvent(const PointerEvent& event) { - //if (_inputMode == Touch) { + if (_inputMode == Touch) { handlePointerEventAsTouch(event); -// } else { -// handlePointerEventAsMouse(event); -// } + } else { + handlePointerEventAsMouse(event); + } +} + +static inline QRectF touchRectForPosition(QPointF centerPoint) +{ + QRectF touchRect(0, 0, 40, 40); + touchRect.moveCenter(centerPoint); + return touchRect; } void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { @@ -411,15 +418,36 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { touchType = QEvent::TouchEnd; } + static QTouchEvent::TouchPoint oldTouchPoint; { QTouchEvent::TouchPoint point; point.setId(event.getID()); point.setState(state); point.setPos(windowPoint); point.setScreenPos(windowPoint); + + + // Gesture recognition uses the screen position for the initial threshold + // but since the canvas translates touch events we actually need to pass + // the screen position as the scene position to deliver the appropriate + // coordinates to the target. + point.setRect(touchRectForPosition(windowPoint)); + point.setSceneRect(touchRectForPosition(windowPoint)); + + if (point.state() == Qt::TouchPointPressed) { + point.setStartScenePos(windowPoint); + oldTouchPoint = point; + } else { + //const QTouchEvent::TouchPoint& oldTouchPoint = _activeTouchPoints[event.getID()]; + point.setStartScenePos(oldTouchPoint.startScenePos()); + point.setLastPos(oldTouchPoint.pos()); + point.setLastScenePos(oldTouchPoint.scenePos()); + } _activeTouchPoints[event.getID()] = point; } + + QTouchEvent touchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); { QList touchPoints; From 58c0141f27c8387848daa9f53128698e3d20a32f Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 12 Sep 2017 19:00:00 +0200 Subject: [PATCH 03/11] Remove unnecessary code --- interface/CMakeLists.txt | 3 - .../qml/controls/FlickableWebViewCore.qml | 42 +-- interface/src/Application.cpp | 247 ------------------ interface/src/Application.h | 20 -- interface/src/ui/overlays/Web3DOverlay.cpp | 8 +- 5 files changed, 26 insertions(+), 294 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 41c7a4d8a4..43e50c6d33 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -17,9 +17,6 @@ endforeach() find_package(Qt5LinguistTools REQUIRED) find_package(Qt5LinguistToolsMacros) -find_package(Qt5Gui) -include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) - if (WIN32) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -bigobj") add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index bf9fe116c5..09436d92f8 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -6,7 +6,7 @@ import QtQuick.Controls 2.2 import "../styles-uit" as StylesUIt -Flickable { +Item { id: flick property alias url: _webview.url @@ -14,17 +14,17 @@ Flickable { property alias webViewCore: _webview property alias webViewCoreProfile: _webview.profile - interactive: true + property bool interactive: false property string userScriptUrl: "" property string urlTag: "noDownload=false"; signal newViewRequestedCallback(var request) signal loadingChangedCallback(var loadRequest) - pressDelay: 300 + //pressDelay: 300 property real previousHeight: height - boundsBehavior: Flickable.StopAtBounds + //boundsBehavior: Flickable.StopAtBounds StylesUIt.HifiConstants { id: hifi @@ -38,17 +38,17 @@ Flickable { // } // } - ScrollBar.vertical: ScrollBar { - id: scrollBar - visible: flick.contentHeight > flick.height +// ScrollBar.vertical: ScrollBar { +// id: scrollBar +// visible: flick.contentHeight > flick.height - contentItem: Rectangle { - opacity: 0.75 - implicitWidth: hifi.dimensions.scrollbarHandleWidth - radius: height / 2 - color: hifi.colors.tableScrollHandleDark - } - } +// contentItem: Rectangle { +// opacity: 0.75 +// implicitWidth: hifi.dimensions.scrollbarHandleWidth +// radius: height / 2 +// color: hifi.colors.tableScrollHandleDark +// } +// } function onLoadingChanged(loadRequest) { if (WebEngineView.LoadStartedStatus === loadRequest.status) { @@ -152,7 +152,7 @@ Flickable { property string newUrl: "" Component.onCompleted: { - width = Qt.binding(function() { return flick.width; }); + //width = Qt.binding(function() { return flick.width; }); webChannel.registerObject("eventBridge", eventBridge); webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); // Ensure the JS from the web-engine makes it to our logging @@ -196,10 +196,10 @@ Flickable { z: 10000 } - MouseArea { - anchors.fill: parent - onWheel: { - flick.flick(0, wheel.angleDelta.y*10) - } - } +// MouseArea { +// anchors.fill: parent +// onWheel: { +// flick.flick(0, wheel.angleDelta.y*10) +// } +// } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 956ace7a28..3650c495f2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -281,34 +281,6 @@ private: Q_LOGGING_CATEGORY(trace_app_input_mouse, "trace.app.input.mouse") -namespace utils { -inline bool isTouchEvent(const QEvent* event) -{ - switch (event->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - return true; - default: - return false; - } -} - -inline bool isMouseEvent(const QEvent* event) -{ - switch (event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseMove: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: - return true; - default: - return false; - } -} - -} - using namespace std; static QTimer locationUpdateTimer; @@ -3091,228 +3063,9 @@ bool Application::eventFilter(QObject* object, QEvent* event) { } } - // We try to be smart, if we received real touch event, we are probably on a device - // with touch screen, and we should not have touch mocking. - - if (!event->spontaneous() || m_realTouchEventReceived) - return false; - - if (utils::isTouchEvent(event)) { - if (m_pendingFakeTouchEventCount) - --m_pendingFakeTouchEventCount; - else - m_realTouchEventReceived = true; - return false; - } - - QQuickWindow* window = qobject_cast(object); - if (!window) { - return false; - } - - m_holdingControl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); - - if (event->type() == QEvent::KeyRelease && static_cast(event)->key() == Qt::Key_Control) { - foreach (int id, m_heldTouchPoints) - if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) { - m_touchPoints[id].setState(Qt::TouchPointReleased); - m_heldTouchPoints.remove(id); - } else - m_touchPoints[id].setState(Qt::TouchPointStationary); - sendTouchEvent(window, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast(event)->timestamp()); - } - - if (utils::isMouseEvent(event)) { - const QMouseEvent* const mouseEvent = static_cast(event); - - QTouchEvent::TouchPoint touchPoint; - touchPoint.setPressure(1); - - QEvent::Type touchType = QEvent::None; - - switch (mouseEvent->type()) { - case QEvent::MouseButtonPress: - touchPoint.setId(mouseEvent->button()); - if (m_touchPoints.contains(touchPoint.id())) { - touchPoint.setState(Qt::TouchPointMoved); - touchType = QEvent::TouchUpdate; - } else { - touchPoint.setState(Qt::TouchPointPressed); - // Check if more buttons are held down than just the event triggering one. - if (mouseEvent->buttons() > mouseEvent->button()) - touchType = QEvent::TouchUpdate; - else - touchType = QEvent::TouchBegin; - } - break; - case QEvent::MouseMove: - if (!mouseEvent->buttons()) { - // We have to swallow the event instead of propagating it, - // since we avoid sending the mouse release events and if the - // Flickable is the mouse grabber it would receive the event - // and would move the content. - event->accept(); - return true; - } - touchType = QEvent::TouchUpdate; - touchPoint.setId(mouseEvent->buttons()); - touchPoint.setState(Qt::TouchPointMoved); - break; - case QEvent::MouseButtonRelease: - // Check if any buttons are still held down after this event. - if (mouseEvent->buttons()) - touchType = QEvent::TouchUpdate; - else - touchType = QEvent::TouchEnd; - touchPoint.setId(mouseEvent->button()); - touchPoint.setState(Qt::TouchPointReleased); - break; - case QEvent::MouseButtonDblClick: - // Eat double-clicks, their accompanying press event is all we need. - event->accept(); - return true; - default: - Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type"); - } - - // A move can have resulted in multiple buttons, so we need check them individually. - if (touchPoint.id() & Qt::LeftButton) - updateTouchPoint(mouseEvent, touchPoint, Qt::LeftButton); - if (touchPoint.id() & Qt::MidButton) - updateTouchPoint(mouseEvent, touchPoint, Qt::MidButton); - if (touchPoint.id() & Qt::RightButton) - updateTouchPoint(mouseEvent, touchPoint, Qt::RightButton); - - if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { - // We avoid sending the release event because the Flickable is - // listening to mouse events and would start a bounce-back - // animation if it received a mouse release. - event->accept(); - return true; - } - - // Update states for all other touch-points - for (QHash::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) { - if (!(it.value().id() & touchPoint.id())) - it.value().setState(Qt::TouchPointStationary); - } - - Q_ASSERT(touchType != QEvent::None); - - if (!sendTouchEvent(window, touchType, mouseEvent->timestamp())) - return false; - - event->accept(); - return true; - } - return false; } -static inline QRectF touchRectForPosition(QPointF centerPoint) { - QRectF touchRect(0, 0, 40, 40); - touchRect.moveCenter(centerPoint); - return touchRect; -} - -void Application::updateTouchPoint(const QMouseEvent* mouseEvent, QTouchEvent::TouchPoint touchPoint, Qt::MouseButton mouseButton) -{ - // Ignore inserting additional touch points if Ctrl isn't held because it produces - // inconsistent touch events and results in assers in the gesture recognizers. - if (!m_holdingControl && m_touchPoints.size() && !m_touchPoints.contains(mouseButton)) - return; - - if (m_holdingControl && touchPoint.state() == Qt::TouchPointReleased) { - m_heldTouchPoints.insert(mouseButton); - return; - } - - // Gesture recognition uses the screen position for the initial threshold - // but since the canvas translates touch events we actually need to pass - // the screen position as the scene position to deliver the appropriate - // coordinates to the target. - touchPoint.setRect(touchRectForPosition(mouseEvent->localPos())); - touchPoint.setSceneRect(touchRectForPosition(mouseEvent->screenPos())); - - if (touchPoint.state() == Qt::TouchPointPressed) - touchPoint.setStartScenePos(mouseEvent->screenPos()); - else { - const QTouchEvent::TouchPoint& oldTouchPoint = m_touchPoints[mouseButton]; - touchPoint.setStartScenePos(oldTouchPoint.startScenePos()); - touchPoint.setLastPos(oldTouchPoint.pos()); - touchPoint.setLastScenePos(oldTouchPoint.scenePos()); - } - - // Update current touch-point. - touchPoint.setId(mouseButton); - m_touchPoints.insert(mouseButton, touchPoint); -} - -bool Application::sendTouchEvent(QQuickWindow* window, QEvent::Type type, ulong timestamp) -{ - static QTouchDevice* device = 0; - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } - - m_pendingFakeTouchEventCount++; - - const QList& currentTouchPoints = m_touchPoints.values(); - Qt::TouchPointStates touchPointStates = 0; - foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) - touchPointStates |= touchPoint.state(); - - QTouchEvent event(type, device, Qt::NoModifier, touchPointStates, currentTouchPoints); - event.setTimestamp(timestamp); - event.setAccepted(false); - - QGuiApplication::notify(window, &event); - - //updateVisualMockTouchPoints(window,m_holdingControl ? currentTouchPoints : QList()); - - // Get rid of touch-points that are no longer valid - foreach (const QTouchEvent::TouchPoint& touchPoint, currentTouchPoints) { - if (touchPoint.state() == Qt::TouchPointReleased) - m_touchPoints.remove(touchPoint.id()); - } - - return event.isAccepted(); -} - -//void Application::updateVisualMockTouchPoints(QQuickWindow* window, const QList& touchPoints) -//{ -// if (touchPoints.isEmpty()) { -// // Hide all touch indicator items. -// foreach (QQuickItem* item, m_activeMockComponents.values()) -// item->setProperty("pressed", false); - -// return; -// } - -// foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) { -// QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id()); - -// if (!mockTouchPointItem) { -// QQmlComponent touchMockPointComponent(window->engine(), QUrl("qrc:///qml/MockTouchPoint.qml")); -// mockTouchPointItem = qobject_cast(touchMockPointComponent.create()); -// Q_ASSERT(mockTouchPointItem); -// m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem); -// mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id())); -// mockTouchPointItem->setParent(window->rootObject()); -// mockTouchPointItem->setParentItem(window->rootObject()); -// } - -// QRectF touchRect = touchPoint.rect(); -// mockTouchPointItem->setX(touchRect.center().x()); -// mockTouchPointItem->setY(touchRect.center().y()); -// mockTouchPointItem->setWidth(touchRect.width()); -// mockTouchPointItem->setHeight(touchRect.height()); -// mockTouchPointItem->setProperty("pressed", QVariant(touchPoint.state() != Qt::TouchPointReleased)); -// } -//} - static bool _altPressed{ false }; void Application::keyPressEvent(QKeyEvent* event) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 9be43c4d1d..c7f83ad28f 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -25,8 +25,6 @@ #include #include -#include - #include #include #include @@ -518,10 +516,6 @@ private: void maybeToggleMenuVisible(QMouseEvent* event) const; void toggleTabletUI(bool shouldOpen = false) const; - void updateTouchPoint(const QMouseEvent *event, QTouchEvent::TouchPoint, Qt::MouseButton); - bool sendTouchEvent(QQuickWindow* window, QEvent::Type, ulong timestamp); - //void updateVisualMockTouchPoints(QQuickWindow *window,const QList &touchPoints); - MainWindow* _window; QElapsedTimer& _sessionRunTimer; @@ -711,20 +705,6 @@ private: RayPickManager _rayPickManager; LaserPointerManager _laserPointerManager; - //touch mocking - bool m_realTouchEventReceived { false }; - int m_pendingFakeTouchEventCount { 0 }; - - QPointF m_lastPos; - QPointF m_lastScreenPos; - QPointF m_startScreenPos; - - QHash m_touchPoints; - QSet m_heldTouchPoints; - QHash m_activeMockComponents; - - bool m_holdingControl { false }; - friend class RenderEventHandler; }; #endif // hifi_Application_h diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index f570d31bd6..214b0c58fc 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -67,7 +67,6 @@ Web3DOverlay::Web3DOverlay() : _dpi(DPI) { _touchDevice.setType(QTouchDevice::TouchScreen); _touchDevice.setName("RenderableWebEntityItemTouchDevice"); _touchDevice.setMaximumTouchPoints(4); - QWindowSystemInterface::registerTouchDevice(&_touchDevice); _geometryId = DependencyManager::get()->allocateID(); connect(this, &Web3DOverlay::requestWebSurface, this, &Web3DOverlay::buildWebSurface); connect(this, &Web3DOverlay::releaseWebSurface, this, &Web3DOverlay::destroyWebSurface); @@ -419,12 +418,14 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { } static QTouchEvent::TouchPoint oldTouchPoint; + { QTouchEvent::TouchPoint point; point.setId(event.getID()); point.setState(state); point.setPos(windowPoint); point.setScreenPos(windowPoint); + point.setPressure(1); // Gesture recognition uses the screen position for the initial threshold @@ -446,8 +447,6 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { _activeTouchPoints[event.getID()] = point; } - - QTouchEvent touchEvent(touchType, &_touchDevice, event.getKeyboardModifiers()); { QList touchPoints; @@ -485,6 +484,9 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { } #endif + touchEvent.setTimestamp((ulong)QDateTime::currentMSecsSinceEpoch()); + touchEvent.setAccepted(false); + if (touchType == QEvent::TouchBegin) { _touchBeginAccepted = QCoreApplication::sendEvent(_webSurface->getWindow(), &touchEvent); } else if (_touchBeginAccepted) { From 1860a2cb16711debbcc651d2030b54ab7a1521df Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 14 Sep 2017 14:40:22 +0200 Subject: [PATCH 04/11] Experimentsl CSS injector --- .../qml/controls/FlickableWebViewCore.qml | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index d1980c7dc3..ac3a3cfb24 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -84,17 +84,32 @@ Item { worldId: WebEngineScript.MainWorld } - userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ] + WebEngineScript { + id: userCSSScript + property string css: "\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }" + sourceCode: "(function() { + var css = document.createElement('style'); + css.setAttribute('type', 'text/css'); + css.appendChild(document.createTextNode('%1')); + document.getElementsByTagName('head')[0].appendChild(" + css + ");})()" + injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished. + worldId: WebEngineScript.MainWorld + } + + userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript, userCSSScript ] property string newUrl: "" + onJavaScriptConsoleMessage: { + console.log("Web Entity JS message: " + sourceID + " at line: " + lineNumber + " " + message); + } Component.onCompleted: { webChannel.registerObject("eventBridge", eventBridge); webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); - // Ensure the JS from the web-engine makes it to our logging - webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) { - console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message); - }); +// // Ensure the JS from the web-engine makes it to our logging +// webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) { +// console.log("Web Entity JS message: " + sourceID + " at line: " + lineNumber + " " + message); +// }); if (webViewCoreUserAgent !== undefined) { webViewCore.profile.httpUserAgent = webViewCoreUserAgent } else { From 9a92b5635d0b3eb24d6b8c192274643b31843b7f Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 5 Oct 2017 15:17:37 +0200 Subject: [PATCH 05/11] Fix too wide web view --- interface/resources/qml/controls/FlickableWebViewCore.qml | 4 +++- interface/src/main.cpp | 2 -- scripts/system/edit.js | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index ac3a3cfb24..aefca21d69 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -21,6 +21,7 @@ Item { signal newViewRequestedCallback(var request) signal loadingChangedCallback(var loadRequest) + width: parent.width property bool interactive: false @@ -53,7 +54,8 @@ Item { WebEngineView { id: webViewCore - anchors.fill: parent + width: parent.width + height: parent.height profile: HFWebEngineProfile; settings.pluginsEnabled: true diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 1493fc53b9..5c07bebc23 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -231,8 +231,6 @@ int main(int argc, const char* argv[]) { // Extend argv to enable WebGL rendering std::vector argvExtended(&argv[0], &argv[argc]); argvExtended.push_back("--ignore-gpu-blacklist"); - argvExtended.push_back("--enable-embedded-switches"); - argvExtended.push_back("--disable-overlay-scrollbar"); int argcExtended = (int)argvExtended.size(); Application app(argcExtended, const_cast(argvExtended.data()), startupTime, runningMarkerExisted); diff --git a/scripts/system/edit.js b/scripts/system/edit.js index a3594cb21b..346f3626b9 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1952,7 +1952,6 @@ var PropertiesTool = function (opts) { data.properties.keyLight.direction.y * DEGREES_TO_RADIANS ); } - print("data properties " + data.properties) Entities.editEntity(selectionManager.selections[0], data.properties); if (data.properties.name !== undefined || data.properties.modelURL !== undefined || data.properties.visible !== undefined || data.properties.locked !== undefined) { From cb21aaff721c41dcfa70fb7d01f7c0dce2c503f0 Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 5 Oct 2017 15:43:07 +0200 Subject: [PATCH 06/11] Accept touch event according to last accepted values --- interface/src/ui/overlays/Web3DOverlay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 6060b342a5..6f7c219ec5 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -468,7 +468,7 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { #endif touchEvent.setTimestamp((ulong)QDateTime::currentMSecsSinceEpoch()); - touchEvent.setAccepted(false); + touchEvent.setAccepted(_touchBeginAccepted); if (touchType == QEvent::TouchBegin) { _touchBeginAccepted = QCoreApplication::sendEvent(_webSurface->getWindow(), &touchEvent); From d6ebd3d828df3c25c9aca4309619e3e5bfa53abd Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 12 Oct 2017 15:33:13 +0200 Subject: [PATCH 07/11] Remove static old touch point --- interface/src/ui/overlays/Web3DOverlay.cpp | 10 +++++----- interface/src/ui/overlays/Web3DOverlay.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 989b51862c..f87ab35189 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -402,8 +402,6 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { touchType = QEvent::TouchEnd; } - static QTouchEvent::TouchPoint oldTouchPoint; - { QTouchEvent::TouchPoint point; point.setId(event.getID()); @@ -425,9 +423,11 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { oldTouchPoint = point; } else { //const QTouchEvent::TouchPoint& oldTouchPoint = _activeTouchPoints[event.getID()]; - point.setStartScenePos(oldTouchPoint.startScenePos()); - point.setLastPos(oldTouchPoint.pos()); - point.setLastScenePos(oldTouchPoint.scenePos()); + if (oldTouchPoint.id() != -1) { + point.setStartScenePos(oldTouchPoint.startScenePos()); + point.setLastPos(oldTouchPoint.pos()); + point.setLastScenePos(oldTouchPoint.scenePos()); + } } _activeTouchPoints[event.getID()] = point; } diff --git a/interface/src/ui/overlays/Web3DOverlay.h b/interface/src/ui/overlays/Web3DOverlay.h index de74b95b3e..0685f3d68e 100644 --- a/interface/src/ui/overlays/Web3DOverlay.h +++ b/interface/src/ui/overlays/Web3DOverlay.h @@ -103,6 +103,7 @@ private: uint8_t _currentMaxFPS { 0 }; bool _mayNeedResize { false }; + QTouchEvent::TouchPoint oldTouchPoint; }; #endif // hifi_Web3DOverlay_h From f524f8a50f6fd783c8eb717c4afe7117a82d8353 Mon Sep 17 00:00:00 2001 From: vladest Date: Fri, 13 Oct 2017 12:56:08 +0200 Subject: [PATCH 08/11] Remove commented code --- interface/resources/qml/controls/FlickableWebViewCore.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index aefca21d69..1e43fad02b 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -108,10 +108,7 @@ Item { Component.onCompleted: { webChannel.registerObject("eventBridge", eventBridge); webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper); -// // Ensure the JS from the web-engine makes it to our logging -// webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) { -// console.log("Web Entity JS message: " + sourceID + " at line: " + lineNumber + " " + message); -// }); + if (webViewCoreUserAgent !== undefined) { webViewCore.profile.httpUserAgent = webViewCoreUserAgent } else { From 13c204400e804130f7ba844336d2cb4e3be61e56 Mon Sep 17 00:00:00 2001 From: vladest Date: Sat, 14 Oct 2017 22:25:49 +0200 Subject: [PATCH 09/11] Reuse activeTouchPoints --- interface/src/ui/overlays/Web3DOverlay.cpp | 6 +++--- interface/src/ui/overlays/Web3DOverlay.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index f87ab35189..92783bf149 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -397,7 +397,8 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (_activeTouchPoints.empty()) { // If the first active touch point is being created, send a begin touchType = QEvent::TouchBegin; - } if (state == Qt::TouchPointReleased && _activeTouchPoints.size() == 1 && _activeTouchPoints.count(event.getID())) { + } + if (state == Qt::TouchPointReleased && _activeTouchPoints.size() == 1 && _activeTouchPoints.count(event.getID())) { // If the last active touch point is being released, send an end touchType = QEvent::TouchEnd; } @@ -420,9 +421,8 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (point.state() == Qt::TouchPointPressed) { point.setStartScenePos(windowPoint); - oldTouchPoint = point; } else { - //const QTouchEvent::TouchPoint& oldTouchPoint = _activeTouchPoints[event.getID()]; + const QTouchEvent::TouchPoint& oldTouchPoint = _activeTouchPoints[event.getID()]; if (oldTouchPoint.id() != -1) { point.setStartScenePos(oldTouchPoint.startScenePos()); point.setLastPos(oldTouchPoint.pos()); diff --git a/interface/src/ui/overlays/Web3DOverlay.h b/interface/src/ui/overlays/Web3DOverlay.h index 0685f3d68e..de74b95b3e 100644 --- a/interface/src/ui/overlays/Web3DOverlay.h +++ b/interface/src/ui/overlays/Web3DOverlay.h @@ -103,7 +103,6 @@ private: uint8_t _currentMaxFPS { 0 }; bool _mayNeedResize { false }; - QTouchEvent::TouchPoint oldTouchPoint; }; #endif // hifi_Web3DOverlay_h From f97a097ce96a51d538a305306f39a3e0789c9982 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 17 Oct 2017 19:31:17 +0200 Subject: [PATCH 10/11] Remove acceft flag. not necessary --- interface/src/ui/overlays/Web3DOverlay.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 92783bf149..2695d5300c 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -470,7 +470,6 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { #endif touchEvent.setTimestamp((ulong)QDateTime::currentMSecsSinceEpoch()); - touchEvent.setAccepted(_touchBeginAccepted); if (touchType == QEvent::TouchBegin) { _touchBeginAccepted = QCoreApplication::sendEvent(_webSurface->getWindow(), &touchEvent); From 567a219e9ce8e8ad8b6569068dd540760ae4a976 Mon Sep 17 00:00:00 2001 From: vladest Date: Sat, 28 Oct 2017 12:01:37 +0200 Subject: [PATCH 11/11] Cleanup. Remove unused functionality --- .../qml/controls/FlickableWebViewCore.qml | 19 +------------------ interface/src/ui/overlays/Web3DOverlay.cpp | 3 +-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index 1e43fad02b..c0784ec15f 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -86,24 +86,7 @@ Item { worldId: WebEngineScript.MainWorld } - WebEngineScript { - id: userCSSScript - property string css: "\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }" - sourceCode: "(function() { - var css = document.createElement('style'); - css.setAttribute('type', 'text/css'); - css.appendChild(document.createTextNode('%1')); - document.getElementsByTagName('head')[0].appendChild(" + css + ");})()" - injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished. - worldId: WebEngineScript.MainWorld - } - - userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript, userCSSScript ] - - property string newUrl: "" - onJavaScriptConsoleMessage: { - console.log("Web Entity JS message: " + sourceID + " at line: " + lineNumber + " " + message); - } + userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ] Component.onCompleted: { webChannel.registerObject("eventBridge", eventBridge); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 75876cd0a4..371d75b20b 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -355,8 +355,7 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) { } } -static inline QRectF touchRectForPosition(QPointF centerPoint) -{ +static inline QRectF touchRectForPosition(QPointF centerPoint) { QRectF touchRect(0, 0, 40, 40); touchRect.moveCenter(centerPoint); return touchRect;