From 783f4f88a856dc6e8b4d90d04ea13a0b8cfd0c5e Mon Sep 17 00:00:00 2001 From: haanhvu Date: Sat, 1 Feb 2025 20:13:41 +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 #1698 --- .../wolvic/ui/widgets/NavigationBarWidget.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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..1614af49ad 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(); @@ -681,6 +683,7 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull } if (mAutoSelectedProjection != VIDEO_PROJECTION_NONE && autoEnter.get()) { + disableHeadlockForVRVideo(); mViewModel.setAutoEnteredVRVideo(true); postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300); } else { @@ -755,11 +758,13 @@ private void enterFullScreenMode() { exitVRVideo(); mAttachedWindow.reCenterFrontWindow(); } else { + disableHeadlockForVRVideo(); // Reproject while reproducing VRVideo mWidgetManager.showVRVideo(mAttachedWindow.getHandle(), projection); } closeFloatingMenus(); } else { + disableHeadlockForVRVideo(); enterVRVideo(projection); } }); @@ -773,6 +778,14 @@ private void enterFullScreenMode() { mWidgetManager.pushWorldBrightness(mBrightnessWidget, mBrightnessWidget.getSelectedBrightness()); } + private void disableHeadlockForVRVideo() { + SettingsStore settingsStore = SettingsStore.getInstance(getContext()); + if (settingsStore.isHeadLockEnabled()) { + settingsStore.setHeadLockEnabled(false); + shouldRestoreHeadLockOnVRVideoExit = true; + } + } + private void exitFullScreenMode() { mWidgetPlacement = mBeforeFullscreenPlacement; updateWidget(); @@ -996,6 +1009,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) {