@@ -371,9 +371,15 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
371
371
VRBrowser::HandleBack ();
372
372
}
373
373
374
+
375
+ const bool pressed = controller.buttonState & ControllerDelegate::BUTTON_TRIGGER ||
376
+ controller.buttonState & ControllerDelegate::BUTTON_TOUCHPAD;
377
+ const bool wasPressed = controller.lastButtonState & ControllerDelegate::BUTTON_TRIGGER ||
378
+ controller.lastButtonState & ControllerDelegate::BUTTON_TOUCHPAD;
379
+
374
380
if (!controller.focused ) {
375
381
const bool focusRequested =
376
- ((controller. buttonState & ControllerDelegate::BUTTON_TRIGGER) && (controller. lastButtonState & ControllerDelegate::BUTTON_TRIGGER) == 0 ) ||
382
+ (pressed && !wasPressed ) ||
377
383
((controller.buttonState & ControllerDelegate::BUTTON_A) && (controller.lastButtonState & ControllerDelegate::BUTTON_A) == 0 ) ||
378
384
((controller.buttonState & ControllerDelegate::BUTTON_B) && (controller.lastButtonState & ControllerDelegate::BUTTON_B) == 0 ) ||
379
385
((controller.buttonState & ControllerDelegate::BUTTON_X) && (controller.lastButtonState & ControllerDelegate::BUTTON_X) == 0 ) ||
@@ -391,34 +397,31 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
391
397
vrb::Vector hitPoint;
392
398
vrb::Vector hitNormal;
393
399
394
- const bool pressed = controller.buttonState & ControllerDelegate::BUTTON_TRIGGER ||
395
- controller.buttonState & ControllerDelegate::BUTTON_TOUCHPAD;
396
- const bool wasPressed = controller.lastButtonState & ControllerDelegate::BUTTON_TRIGGER ||
397
- controller.lastButtonState & ControllerDelegate::BUTTON_TOUCHPAD;
398
-
399
400
bool isResizing = resizingWidget && resizingWidget->IsResizingActive ();
400
- bool isDragging = pressed && wasPressed && controller.widget && !isResizing;
401
+ WidgetPtr previousWidget = controller.widget ? GetWidget (controller.widget ) : nullptr ;
402
+ bool isDragging = pressed && wasPressed && previousWidget && !isResizing;
401
403
if (isDragging) {
402
- WidgetPtr widget = GetWidget (controller.widget );
403
404
vrb::Vector result;
404
405
vrb::Vector normal;
405
406
float distance = 0 .0f ;
406
407
bool isInWidget = false ;
407
- if (widget->TestControllerIntersection (start, direction, result, normal, false , isInWidget, distance)) {
408
- hitWidget = widget;
408
+ if (previousWidget->TestControllerIntersection (start, direction, result, normal, false ,
409
+ isInWidget, distance)) {
410
+ hitWidget = previousWidget;
409
411
hitPoint = result;
410
412
hitNormal = normal;
411
413
}
412
-
413
414
} else {
414
415
for (const WidgetPtr& widget: widgets) {
415
- if (isResizing && resizingWidget != widget) {
416
- // Don't interact with other widgets when resizing gesture is active.
417
- continue ;
418
- }
419
- if (movingWidget && movingWidget->GetWidget () != widget) {
420
- // Don't interact with other widgets when moving gesture is active.
421
- continue ;
416
+ if (controller.focused ) {
417
+ if (isResizing && resizingWidget != widget) {
418
+ // Don't interact with other widgets when resizing gesture is active.
419
+ continue ;
420
+ }
421
+ if (movingWidget && movingWidget->GetWidget () != widget) {
422
+ // Don't interact with other widgets when moving gesture is active.
423
+ continue ;
424
+ }
422
425
}
423
426
vrb::Vector result;
424
427
vrb::Vector normal;
@@ -436,7 +439,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
436
439
}
437
440
}
438
441
439
- if ((!hitWidget || !hitWidget->IsResizing ()) && resizingWidget) {
442
+ if (controller. focused && (!hitWidget || !hitWidget->IsResizing ()) && resizingWidget) {
440
443
resizingWidget->HoverExitResize ();
441
444
resizingWidget.reset ();
442
445
}
@@ -453,7 +456,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
453
456
}
454
457
}
455
458
456
- if (movingWidget && movingWidget->IsMoving (controller.index )) {
459
+ if (controller. focused && movingWidget && movingWidget->IsMoving (controller.index )) {
457
460
if (!pressed && wasPressed) {
458
461
movingWidget->EndMoving ();
459
462
} else {
@@ -463,7 +466,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
463
466
aRelayoutWidgets = true ;
464
467
}
465
468
}
466
- } else if (hitWidget && hitWidget->IsResizing () && controller. focused ) {
469
+ } else if (controller. focused && hitWidget && hitWidget->IsResizing ()) {
467
470
bool aResized = false , aResizeEnded = false ;
468
471
hitWidget->HandleResize (hitPoint, pressed, aResized, aResizeEnded);
469
472
0 commit comments