From ed2d88e13234353b3207af548cf6e9b9fe860162 Mon Sep 17 00:00:00 2001 From: haanhvu Date: Wed, 5 Feb 2025 17:41:28 +0700 Subject: [PATCH] Disable headlock when in VR videos VR videos are meant for users to be immersed in the whole space around them. Because headlock locks users in the front of them, it needs to be disabled in VR videos. If users enabled headlock before entering VR videos, we disable it when VR videos show and reenable it when they are exited. Fixes Igalia#1698 --- .../com/igalia/wolvic/VRBrowserActivity.java | 1 + .../wolvic/ui/widgets/NavigationBarWidget.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java b/app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java index 32a7e864d0..922e7a37af 100644 --- a/app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java +++ b/app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java @@ -2022,6 +2022,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permi @Override public void showVRVideo(final int aWindowHandle, final @VideoProjectionMenuWidget.VideoProjectionFlags int aVideoProjection) { + getNavigationBar().disableHeadlockForVRVideo(); queueRunnable(() -> showVRVideoNative(aWindowHandle, aVideoProjection)); } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java index 4b1fc2ad50..7a0fa91ab9 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java @@ -99,6 +99,8 @@ public class NavigationBarWidget extends UIWidget implements WSession.Navigation private static final int POPUP_NOTIFICATION_ID = 3; private static final int WEB_APP_ADDED_NOTIFICATION_ID = 4; + private boolean shouldRestoreHeadLockOnVRVideoExit; + public interface NavigationListener { void onBack(); void onForward(); @@ -773,6 +775,14 @@ private void enterFullScreenMode() { mWidgetManager.pushWorldBrightness(mBrightnessWidget, mBrightnessWidget.getSelectedBrightness()); } + public void disableHeadlockForVRVideo() { + SettingsStore settingsStore = SettingsStore.getInstance(getContext()); + if (settingsStore.isHeadLockEnabled()) { + settingsStore.setHeadLockEnabled(false); + shouldRestoreHeadLockOnVRVideoExit = true; + } + } + private void exitFullScreenMode() { mWidgetPlacement = mBeforeFullscreenPlacement; updateWidget(); @@ -996,6 +1006,10 @@ private void exitVRVideo() { mWidgetManager.setCylinderDensityForce(mSavedCylinderDensity); // Reposition UI in front of the user when exiting a VR video. mWidgetManager.recenterUIYaw(WidgetManagerDelegate.YAW_TARGET_ALL); + + if (shouldRestoreHeadLockOnVRVideoExit) { + SettingsStore.getInstance(getContext()).setHeadLockEnabled(true); + } } private void setResizePreset(float aMultiplier) {