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 authored and svillar committed Feb 6, 2025
1 parent 9cc650e commit 8a40a50
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public class VRBrowserActivity extends PlatformActivity implements WidgetManager
public static final String EXTRA_LAUNCH_IMMERSIVE_PARENT_XPATH = "launch_immersive_parent_xpath";
public static final String EXTRA_LAUNCH_IMMERSIVE_ELEMENT_XPATH = "launch_immersive_element_xpath";

private boolean shouldRestoreHeadLockOnVRVideoExit;

private BroadcastReceiver mCrashReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Expand Down Expand Up @@ -2022,12 +2024,20 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permi

@Override
public void showVRVideo(final int aWindowHandle, final @VideoProjectionMenuWidget.VideoProjectionFlags int aVideoProjection) {
if (mSettings.isHeadLockEnabled()) {
mSettings.setHeadLockEnabled(false);
shouldRestoreHeadLockOnVRVideoExit = true;
}
queueRunnable(() -> showVRVideoNative(aWindowHandle, aVideoProjection));
}

@Override
public void hideVRVideo() {
queueRunnable(this::hideVRVideoNative);

if (shouldRestoreHeadLockOnVRVideoExit) {
mSettings.setHeadLockEnabled(true);
}
}

@Override
Expand Down

0 comments on commit 8a40a50

Please sign in to comment.