Skip to content

Commit

Permalink
Disable headlock when in VR videos
Browse files Browse the repository at this point in the history
VR videos are meant for users to be immersed in the whole space around them. Because headlocks 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
  • Loading branch information
haanhvu committed Jan 30, 2025
1 parent 1e871dd commit 120e0b9
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 static boolean disabledHeadlockForVRVideo;

public interface NavigationListener {
void onBack();
void onForward();
Expand Down Expand Up @@ -681,6 +683,12 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull
}

if (mAutoSelectedProjection != VIDEO_PROJECTION_NONE && autoEnter.get()) {
SettingsStore settingsStore = SettingsStore.getInstance(getContext());
if (settingsStore.isHeadLockEnabled()) {
settingsStore.setHeadLockEnabled(false);
disabledHeadlockForVRVideo = true;
}

mViewModel.setAutoEnteredVRVideo(true);
postDelayed(() -> enterVRVideo(mAutoSelectedProjection), 300);
} else {
Expand All @@ -696,6 +704,9 @@ public void onMediaFullScreen(@NonNull WMediaSession mediaSession, boolean aFull

if (isInVRVideo()) {
exitVRVideo();
if (disabledHeadlockForVRVideo) {
SettingsStore.getInstance(getContext()).setHeadLockEnabled(true);
}
}
}
}
Expand Down Expand Up @@ -755,11 +766,22 @@ private void enterFullScreenMode() {
exitVRVideo();
mAttachedWindow.reCenterFrontWindow();
} else {
SettingsStore settingsStore = SettingsStore.getInstance(getContext());
if (settingsStore.isHeadLockEnabled()) {
settingsStore.setHeadLockEnabled(false);
disabledHeadlockForVRVideo = true;
}

// Reproject while reproducing VRVideo
mWidgetManager.showVRVideo(mAttachedWindow.getHandle(), projection);
}
closeFloatingMenus();
} else {
SettingsStore settingsStore = SettingsStore.getInstance(getContext());
if (settingsStore.isHeadLockEnabled()) {
settingsStore.setHeadLockEnabled(false);
disabledHeadlockForVRVideo = true;
}
enterVRVideo(projection);
}
});
Expand Down Expand Up @@ -996,6 +1018,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 (disabledHeadlockForVRVideo) {
SettingsStore.getInstance(getContext()).setHeadLockEnabled(true);
}
}

private void setResizePreset(float aMultiplier) {
Expand Down

0 comments on commit 120e0b9

Please sign in to comment.