@@ -67,7 +67,8 @@ class WindowsState {
6767 public static final int MAX_WINDOWS = 3 ;
6868 private WindowWidget mFullscreenWindow ;
6969 private WindowPlacement mPrevWindowPlacement ;
70- private boolean mCurvedMode = false ;
70+ private boolean mStoredCurvedMode = false ;
71+ private boolean mForcedCurvedMode = false ;
7172
7273 public enum WindowPlacement {
7374 FRONT (0 ),
@@ -93,6 +94,8 @@ public Windows(Context aContext) {
9394 mRegularWindows = new ArrayList <>();
9495 mPrivateWindows = new ArrayList <>();
9596
97+ mStoredCurvedMode = SettingsStore .getInstance (mContext ).getCylinderDensity () > 0.0f ;
98+
9699 restoreWindows ();
97100 }
98101
@@ -200,7 +203,7 @@ public WindowWidget addWindow() {
200203 updateMaxWindowScales ();
201204 mWidgetManager .addWidget (newWindow );
202205 focusWindow (newWindow );
203- updateCurvedMode ();
206+ updateCurvedMode (true );
204207 updateViews ();
205208 return newWindow ;
206209 }
@@ -217,7 +220,7 @@ private WindowWidget addWindow(@NonNull WindowState aState) {
217220 newWindow .getPlacement ().worldWidth = aState .worldWidth ;
218221 newWindow .setRestored (true );
219222 placeWindow (newWindow , aState .placement );
220- updateCurvedMode ();
223+ updateCurvedMode (true );
221224
222225 mWidgetManager .addWidget (newWindow );
223226 return newWindow ;
@@ -362,7 +365,7 @@ public void enterPrivateMode() {
362365 return ;
363366 }
364367 mPrivateMode = true ;
365- updateCurvedMode ();
368+ updateCurvedMode (true );
366369 for (WindowWidget window : mRegularWindows ) {
367370 setWindowVisible (window , false );
368371 }
@@ -388,7 +391,7 @@ public void exitPrivateMode() {
388391 return ;
389392 }
390393 mPrivateMode = false ;
391- updateCurvedMode ();
394+ updateCurvedMode (true );
392395 for (WindowWidget window : mRegularWindows ) {
393396 setWindowVisible (window , true );
394397 }
@@ -510,7 +513,7 @@ private void removeWindow(@NonNull WindowWidget aWindow) {
510513 aWindow .getSessionStack ().removeContentListener (this );
511514 aWindow .close ();
512515 updateMaxWindowScales ();
513- updateCurvedMode ();
516+ updateCurvedMode (true );
514517
515518 if (mPrivateMode ) {
516519 TelemetryWrapper .openWindowsEvent (mPrivateWindows .size () + 1 , mPrivateWindows .size (), true );
@@ -525,6 +528,10 @@ private void setWindowVisible(@NonNull WindowWidget aWindow, boolean aVisible) {
525528 }
526529
527530 private void placeWindow (@ NonNull WindowWidget aWindow , WindowPlacement aPosition ) {
531+ placeWindow (aWindow , aPosition , mStoredCurvedMode || mForcedCurvedMode );
532+ }
533+
534+ private void placeWindow (@ NonNull WindowWidget aWindow , WindowPlacement aPosition , boolean curvedMode ) {
528535 WidgetPlacement placement = aWindow .getPlacement ();
529536 aWindow .setWindowPlacement (aPosition );
530537 switch (aPosition ) {
@@ -546,7 +553,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
546553 placement .parentAnchorY = 0.0f ;
547554 placement .rotationAxisX = 0 ;
548555 placement .rotationAxisZ = 0 ;
549- if (mCurvedMode ) {
556+ if (curvedMode ) {
550557 placement .rotationAxisY = 0 ;
551558 placement .rotation = 0 ;
552559 } else {
@@ -564,7 +571,7 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
564571 placement .parentAnchorY = 0.0f ;
565572 placement .rotationAxisX = 0 ;
566573 placement .rotationAxisZ = 0 ;
567- if (mCurvedMode ) {
574+ if (curvedMode ) {
568575 placement .rotationAxisY = 0 ;
569576 placement .rotation = 0 ;
570577 } else {
@@ -578,19 +585,37 @@ private void placeWindow(@NonNull WindowWidget aWindow, WindowPlacement aPositio
578585 }
579586 }
580587
581- public void updateCurvedMode () {
588+ public void updateCurvedMode (boolean force ) {
582589 float density = SettingsStore .getInstance (mContext ).getCylinderDensity ();
583- boolean curved = getCurrentWindows ().size () > 1 || density > 0 ;
584- if (curved != mCurvedMode ) {
585- mCurvedMode = curved ;
586- for (WindowWidget window : getCurrentWindows ()) {
587- placeWindow (window , window .getWindowPlacement ());
590+ boolean storedCurvedMode = density > 0.0f ;
591+ boolean forcedCurvedMode = getCurrentWindows ().size () > 1 ;
592+
593+ if (force ) {
594+ boolean curved = forcedCurvedMode || storedCurvedMode ;
595+
596+ for (WindowWidget window : getCurrentWindows ()) {
597+ placeWindow (window , window .getWindowPlacement (), curved );
598+ }
599+ updateViews ();
600+ mWidgetManager .setCylinderDensity (curved ? SettingsStore .CYLINDER_DENSITY_ENABLED_DEFAULT : density );
601+
602+ } else if ((storedCurvedMode != mStoredCurvedMode ) || (forcedCurvedMode != mForcedCurvedMode )) {
603+ mStoredCurvedMode = storedCurvedMode ;
604+ mForcedCurvedMode = forcedCurvedMode ;
605+
606+ boolean curved = mStoredCurvedMode || mForcedCurvedMode ;
607+ for (WindowWidget window : getCurrentWindows ()) {
608+ placeWindow (window , window .getWindowPlacement (), curved );
588609 }
589610 updateViews ();
590611 mWidgetManager .setCylinderDensity (curved ? SettingsStore .CYLINDER_DENSITY_ENABLED_DEFAULT : density );
591612 }
592613 }
593614
615+ public int getWindowsCount () {
616+ return getCurrentWindows ().size ();
617+ }
618+
594619 private void updateViews () {
595620 WindowWidget frontWindow = getFrontWindow ();
596621 WindowWidget leftWindow = getLeftWindow ();
0 commit comments