Skip to content

Commit

Permalink
Do not resize fullscreen window size if the window size is actually b…
Browse files Browse the repository at this point in the history
…igger than the fullscreen min size threshold
  • Loading branch information
MortimerGoro committed Jul 11, 2019
1 parent 2760865 commit ddc1473
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,20 @@ public void setBrowserWidget(WindowWidget aWidget) {
}

private void setFullScreenSize() {
final float minScale = WidgetPlacement.floatDimension(getContext(), R.dimen.window_fullscreen_min_scale);
mSizeBeforeFullScreen.copyFrom(mWindowWidget.getPlacement());
// Set browser fullscreen size
float aspect = SettingsStore.getInstance(getContext()).getWindowAspect();
Media media = SessionStore.get().getFullScreenVideo();
if (media != null && media.getWidth() > 0 && media.getHeight() > 0) {
aspect = (float)media.getWidth() / (float)media.getHeight();
}
mWindowWidget.resizeByMultiplier(aspect,1.75f);
float scale = mWindowWidget.getCurrentScale();
// Enforce min fullscreen size.
// If current window area is larger only resize if the aspect changes (e.g. media).
if (scale < minScale || aspect != mWindowWidget.getCurrentAspect()) {
mWindowWidget.resizeByMultiplier(aspect, Math.max(scale, minScale));
}
}

private void enterFullScreenMode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,20 @@ public void resizeByMultiplier(float aspect, float multiplier) {
handleResizeEvent(targetWidth, targetHeight);
}

public float getCurrentScale() {
float currentAspect = getCurrentAspect();
float currentWorldHeight = mWidgetPlacement.worldWidth / currentAspect;
float currentArea = mWidgetPlacement.worldWidth * currentWorldHeight;
float defaultWidth = WidgetPlacement.floatDimension(getContext(), R.dimen.window_world_width);
float defaultHeight = defaultWidth / SettingsStore.getInstance(getContext()).getWindowAspect();
float defaultArea = defaultWidth * defaultHeight;
return currentArea / defaultArea;
}

public float getCurrentAspect() {
return (float) mWidgetPlacement.width / (float) mWidgetPlacement.height;
}

public int getBorderWidth() {
return mBorderWidth;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<item name="window_world_y" format="float" type="dimen">0.2</item>
<item name="window_world_z" format="float" type="dimen">-4.2</item>
<item name="browser_children_z_distance" format="float" type="dimen">1.5</item>
<item name="window_fullscreen_min_scale" format="float" type="dimen">1.75</item>

<!-- Navigation bar -->
<dimen name="navigation_bar_width">720dp</dimen>
Expand Down

0 comments on commit ddc1473

Please sign in to comment.