Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Fix stuck in fullscreen mode when exiting private browsing. Fixes #739 (
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored Nov 23, 2018
1 parent 49290ad commit 9426226
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,19 @@ public boolean isInFullScreen() {
return false;
}

public boolean isInFullScreen(GeckoSession aSession) {
Integer sessionId = getSessionId(aSession);
if (sessionId == null) {
return false;
}
State state = mSessions.get(sessionId);
if (state != null) {
return state.mFullScreen;
}

return false;
}

public void exitFullScreen() {
if (mCurrentSession == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,13 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) {
for (CustomUIButton button : mButtons) {
button.setPrivateMode(isPrivateMode);
}
boolean isFullScreen = SessionStore.get().isInFullScreen(aSession);
if (isFullScreen && !mIsInFullScreenMode) {
enterFullScreenMode();
} else if (!isFullScreen && mIsInFullScreenMode) {
exitVRVideo();
exitFullScreenMode();
}
}

// NavigationURLBarDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ private void initialize(Context aContext) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

SessionStore.get().exitPrivateMode();
});

Expand All @@ -60,7 +59,6 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
Context context = getContext();
aPlacement.width = WidgetPlacement.dpDimension(context, R.dimen.top_bar_width);
aPlacement.height = WidgetPlacement.dpDimension(context, R.dimen.top_bar_height);
// FIXME: Something wrong with the DPI ratio? Revert to top_bar_world_width when fixed
aPlacement.worldWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width) * aPlacement.width/getWorldWidth();
aPlacement.translationY = WidgetPlacement.unitFromMeters(context, R.dimen.top_bar_world_y);
aPlacement.anchorX = 0.5f;
Expand Down Expand Up @@ -104,6 +102,7 @@ public void onCurrentSessionChange(GeckoSession aSession, int aId) {
mCloseButton.setPrivateMode(isPrivateMode);
}

@Override
public void setVisible(boolean isVisible) {
getPlacement().visible = isVisible;

Expand All @@ -116,19 +115,8 @@ public void setVisible(boolean isVisible) {
// WidgetManagerDelegate.UpdateListener
@Override
public void onWidgetUpdate(Widget aWidget) {
if (aWidget != mBrowserWidget) {
return;
if (aWidget == mBrowserWidget && isVisible()) {
mWidgetManager.updateWidget(this);
}

// Browser window may have been resized, adjust the navigation bar
float targetWidth = aWidget.getPlacement().worldWidth;
// FIXME: Something wrong with the DPI ratio? Revert to top_bar_world_width when fixed
float defaultWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width) * 40/720;
targetWidth = Math.max(defaultWidth, targetWidth);

float ratio = targetWidth / defaultWidth;
mWidgetPlacement.worldWidth = targetWidth;
mWidgetPlacement.width = (int) (WidgetPlacement.dpDimension(getContext(), R.dimen.top_bar_width) * ratio);
mWidgetManager.updateWidget(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ private void initialize() {
mWidgetManager = (WidgetManagerDelegate) getContext();
mWidgetPlacement = new WidgetPlacement(getContext());
mHandle = mWidgetManager.newWidgetHandle();
mWorldWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.world_width);
initializeWidgetPlacement(mWidgetPlacement);
mInitialWidth = mWidgetPlacement.width;
mInitialHeight = mWidgetPlacement.height;
mWorldWidth = WidgetPlacement.pixelDimension(getContext(), R.dimen.world_width);
// Transparent border useful for TimeWarp Layers and better aliasing.
final float scale = getResources().getDisplayMetrics().density;
int padding_px = (int) (mBorderWidth * scale + 0.5f);
Expand Down

0 comments on commit 9426226

Please sign in to comment.