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

Commit

Permalink
Force curved mode in multiwindow
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Aug 8, 2019
1 parent 62079de commit 2f64af6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ protected void onCreate(Bundle savedInstanceState) {
queueRunnable(() -> createOffscreenDisplay());
final String tempPath = getCacheDir().getAbsolutePath();
queueRunnable(() -> setTemporaryFilePath(tempPath));
setCylinderDensity(SettingsStore.getInstance(this).getCylinderDensity());
updateFoveatedLevel();

initializeWidgets();
Expand Down Expand Up @@ -1270,7 +1269,7 @@ public void resetUIYaw() {
public void setCylinderDensity(final float aDensity) {
queueRunnable(() -> setCylinderDensityNative(aDensity));
if (mWindows != null) {
mWindows.onCurvedModeChanged();
mWindows.updateCurvedMode();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class WindowsState {
public static final int MAX_WINDOWS = 3;
private WindowWidget mFullscreenWindow;
private WindowPlacement mPrevWindowPlacement;
private boolean mCurvedMode = false;

public enum WindowPlacement{
FRONT(0),
Expand Down Expand Up @@ -196,6 +197,7 @@ public WindowWidget addWindow() {
updateMaxWindowScales();
mWidgetManager.addWidget(newWindow);
focusWindow(newWindow);
updateCurvedMode();
updateViews();
return newWindow;
}
Expand All @@ -212,6 +214,7 @@ private WindowWidget addWindow(WindowState aState) {
newWindow.getPlacement().worldWidth = aState.worldWidth;
newWindow.setRestored(true);
placeWindow(newWindow, aState.placement);
updateCurvedMode();

mWidgetManager.addWidget(newWindow);
return newWindow;
Expand Down Expand Up @@ -354,6 +357,7 @@ public void enterPrivateMode() {
return;
}
mPrivateMode = true;
updateCurvedMode();
for (WindowWidget window: mRegularWindows) {
setWindowVisible(window, false);
}
Expand All @@ -377,6 +381,7 @@ public void exitPrivateMode() {
return;
}
mPrivateMode = false;
updateCurvedMode();
for (WindowWidget window: mRegularWindows) {
setWindowVisible(window, true);
}
Expand Down Expand Up @@ -494,6 +499,7 @@ private void removeWindow(@NonNull WindowWidget aWindow) {
aWindow.getSessionStack().removeContentListener(this);
aWindow.close();
updateMaxWindowScales();
updateCurvedMode();

if (aWindow.getSessionStack().isPrivateMode())
TelemetryWrapper.openWindowsEvent(mPrivateWindows.size()+1, mPrivateWindows.size(), true);
Expand All @@ -509,7 +515,6 @@ private void setWindowVisible(@NonNull WindowWidget aWindow, boolean aVisible) {
private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPosition) {
WidgetPlacement placement = aWindow.getPlacement();
aWindow.setWindowPlacement(aPosition);
boolean curved = SettingsStore.getInstance(mContext).getCylinderDensity() > 0;
switch (aPosition) {
case FRONT:
placement.anchorX = 0.5f;
Expand All @@ -529,7 +534,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
placement.parentAnchorY = 0.0f;
placement.rotationAxisX = 0;
placement.rotationAxisZ = 0;
if (curved) {
if (mCurvedMode) {
placement.rotationAxisY = 0;
placement.rotation = 0;
} else {
Expand All @@ -547,7 +552,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
placement.parentAnchorY = 0.0f;
placement.rotationAxisX = 0;
placement.rotationAxisZ = 0;
if (curved) {
if (mCurvedMode) {
placement.rotationAxisY = 0;
placement.rotation = 0;
} else {
Expand All @@ -561,6 +566,19 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
}
}

public void updateCurvedMode() {
float density = SettingsStore.getInstance(mContext).getCylinderDensity();
boolean curved = getCurrentWindows().size() > 1 || density > 0;
if (curved != mCurvedMode) {
mCurvedMode = curved;
for (WindowWidget window: getCurrentWindows()) {
placeWindow(window, window.getWindowPlacement());
}
updateViews();
mWidgetManager.setCylinderDensity(curved ? SettingsStore.CYLINDER_DENSITY_ENABLED_DEFAULT : density);
}
}

private void updateViews() {
WindowWidget frontWindow = getFrontWindow();
WindowWidget leftWindow = getLeftWindow();
Expand Down Expand Up @@ -619,12 +637,6 @@ private WindowWidget createWindow() {
return window;
}

public void onCurvedModeChanged() {
for (WindowWidget window: getCurrentWindows()) {
placeWindow(window, window.getWindowPlacement());
}
updateViews();
}

// Tray Listener
@Override
Expand Down

0 comments on commit 2f64af6

Please sign in to comment.