diff --git a/app/src/main/cpp/BrowserWorld.cpp b/app/src/main/cpp/BrowserWorld.cpp index e54ef42f30..0be8210e35 100644 --- a/app/src/main/cpp/BrowserWorld.cpp +++ b/app/src/main/cpp/BrowserWorld.cpp @@ -368,9 +368,16 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { const bool wasPressed = controller.lastButtonState & ControllerDelegate::BUTTON_TRIGGER || controller.lastButtonState & ControllerDelegate::BUTTON_TOUCHPAD; - bool isDrag = false; - if (pressed && wasPressed && controller.widget) { - isDrag = true; + bool dragging = false; + bool wasDragging = false; + if (wasPressed) { + if (pressed) { + if (controller.widget) { + dragging = true; + } + } else { + wasDragging = true; + } } const vrb::Vector start = controller.StartPoint(); @@ -381,16 +388,23 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { vrb::Vector hitPoint; vrb::Vector hitNormal; - if (isDrag) { + if (dragging) { WidgetPtr widget = GetWidget(controller.widget); + if (resizingWidget && resizingWidget->IsResizingActive() && resizingWidget != widget) { + // Don't interact with other widgets when resizing gesture is active. + continue; + } + if (movingWidget && movingWidget->GetWidget() != widget) { + // Don't interact with other widgets when moving gesture is active. + continue; + } vrb::Vector result; vrb::Vector normal; float distance = 0.0f; bool isInWidget = false; - const bool clamp = !widget->IsResizing() && !movingWidget && !isDrag; + const bool clamp = !widget->IsResizing() && !movingWidget && !dragging; if (widget->TestControllerIntersection(start, direction, result, normal, clamp, isInWidget, distance)) { hitWidget = widget; - hitDistance = distance; hitPoint = result; hitNormal = normal; } @@ -429,7 +443,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { if (controller.pointer) { controller.pointer->SetVisible(hitWidget.get() != nullptr); controller.pointer->SetHitWidget(hitWidget); - if (hitWidget || isDrag) { + if (hitWidget || dragging) { vrb::Matrix translation = vrb::Matrix::Translation(hitPoint); vrb::Matrix localRotation = vrb::Matrix::Rotation(hitNormal); vrb::Matrix reorient = device->GetReorientTransform(); @@ -517,25 +531,11 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) { } } } else if (controller.widget) { - if(isDrag) { - WidgetPtr widget = GetWidget(controller.widget); - vrb::Vector result; - vrb::Vector normal; - float distance = 0.0f; - bool isInWidget = false; - const bool clamp = !widget->IsResizing() && !movingWidget; - if (widget->TestControllerIntersection(start, direction, result, normal, clamp, isInWidget, distance)) { - hitPoint = result; - } - - float theX = 0.0f, theY = 0.0f; - widget->ConvertToWidgetCoordinates(hitPoint, theX, theY, false); - VRBrowser::HandleMotionEvent(controller.widget, controller.index, (jboolean) pressed, theX, theY); - - } else { - VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f); - controller.widget = 0; + if (wasDragging) { + VRBrowser::HandleMotionEvent(controller.widget, controller.index, (jboolean) pressed, controller.lastTouchX, controller.lastTouchY); } + VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f); + controller.widget = 0; } else if (wasPressed != pressed) { VRBrowser::HandleMotionEvent(0, controller.index, (jboolean) pressed, 0.0f, 0.0f);