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 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
  • Loading branch information
haanhvu committed Feb 5, 2025
1 parent 57d2dc8 commit ed2d88e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
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 boolean shouldRestoreHeadLockOnVRVideoExit;

public interface NavigationListener {
void onBack();
void onForward();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ed2d88e

Please sign in to comment.