OSDN Git Service

Add home StackBox to all DisplayContent.
authorCraig Mautner <cmautner@google.com>
Wed, 7 Aug 2013 01:00:25 +0000 (18:00 -0700)
committerCraig Mautner <cmautner@google.com>
Wed, 7 Aug 2013 01:07:13 +0000 (18:07 -0700)
Each display needs a stack and a stack box to contain windows.

Fixes bug 10161525.

Change-Id: Ic617cdf5a082ae68f0589e826ecbb37d8fba52ac

services/java/com/android/server/wm/DimLayer.java
services/java/com/android/server/wm/DisplayContent.java
services/java/com/android/server/wm/TaskStack.java
services/java/com/android/server/wm/WindowManagerService.java

index 7839d06..39e664f 100644 (file)
@@ -48,9 +48,10 @@ public class DimLayer {
     /** Time in milliseconds to take to transition from mStartAlpha to mTargetAlpha */
     long mDuration;
 
-    DimLayer(WindowManagerService service, int displayId) {
+    DimLayer(WindowManagerService service, DisplayContent displayContent) {
+        mDisplayContent = displayContent;
+        final int displayId = displayContent.getDisplayId();
         if (DEBUG) Slog.v(TAG, "Ctor: displayId=" + displayId);
-        mDisplayContent = service.getDisplayContentLocked(displayId);
         SurfaceControl.openTransaction();
         try {
             if (WindowManagerService.DEBUG_SURFACE_TRACE) {
index 74676ca..2dcdcdd 100644 (file)
@@ -111,14 +111,25 @@ class DisplayContent {
     /** Save allocating when calculating rects */
     Rect mTmpRect = new Rect();
 
+    final WindowManagerService mService;
+
     /**
      * @param display May not be null.
+     * @param service TODO(cmautner):
      */
-    DisplayContent(Display display) {
+    DisplayContent(Display display, WindowManagerService service) {
         mDisplay = display;
         mDisplayId = display.getDisplayId();
         display.getDisplayInfo(mDisplayInfo);
         isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
+        mService = service;
+
+        StackBox newBox = new StackBox(service, this, null);
+        mStackBoxes.add(newBox);
+        TaskStack newStack = new TaskStack(service, HOME_STACK_ID, this);
+        newStack.mStackBox = newBox;
+        newBox.mStack = newStack;
+        mHomeStack = newStack;
     }
 
     int getDisplayId() {
@@ -201,22 +212,15 @@ class DisplayContent {
     }
 
     /** Refer to {@link WindowManagerService#createStack(int, int, int, float)} */
-    TaskStack createStack(WindowManagerService service, int stackId, int relativeStackBoxId,
-            int position, float weight) {
+    TaskStack createStack(int stackId, int relativeStackBoxId, int position, float weight) {
         TaskStack newStack = null;
         if (DEBUG_STACK) Slog.d(TAG, "createStack: stackId=" + stackId + " relativeStackBoxId="
                 + relativeStackBoxId + " position=" + position + " weight=" + weight);
-        if (mStackBoxes.isEmpty()) {
-            if (stackId != HOME_STACK_ID) {
-                throw new IllegalArgumentException("createStack: First stackId not "
-                        + HOME_STACK_ID);
+        if (stackId == HOME_STACK_ID) {
+            if (mStackBoxes.size() != 1) {
+                throw new IllegalArgumentException("createStack: HOME_STACK_ID (0) not first.");
             }
-            StackBox newBox = new StackBox(service, this, null);
-            mStackBoxes.add(newBox);
-            newStack = new TaskStack(service, stackId, this);
-            newStack.mStackBox = newBox;
-            newBox.mStack = newStack;
-            mHomeStack = newStack;
+            newStack = mHomeStack;
         } else {
             int stackBoxNdx;
             for (stackBoxNdx = mStackBoxes.size() - 1; stackBoxNdx >= 0; --stackBoxNdx) {
@@ -225,8 +229,8 @@ class DisplayContent {
                         || position == StackBox.TASK_STACK_GOES_UNDER) {
                     // Position indicates a new box is added at top level only.
                     if (box.contains(relativeStackBoxId)) {
-                        StackBox newBox = new StackBox(service, this, null);
-                        newStack = new TaskStack(service, stackId, this);
+                        StackBox newBox = new StackBox(mService, this, null);
+                        newStack = new TaskStack(mService, stackId, this);
                         newStack.mStackBox = newBox;
                         newBox.mStack = newStack;
                         final int offset = position == StackBox.TASK_STACK_GOES_OVER ? 1 : 0;
index 29156be..7bb6734 100644 (file)
@@ -71,8 +71,8 @@ public class TaskStack {
         mStackId = stackId;
         mDisplayContent = displayContent;
         final int displayId = displayContent.getDisplayId();
-        mDimLayer = new DimLayer(service, displayId);
-        mAnimationBackgroundSurface = new DimLayer(service, displayId);
+        mDimLayer = new DimLayer(service, displayContent);
+        mAnimationBackgroundSurface = new DimLayer(service, displayContent);
     }
 
     DisplayContent getDisplayContent() {
index 0750e71..42ed673 100644 (file)
@@ -4832,8 +4832,8 @@ public class WindowManagerService extends IWindowManager.Stub
             final int numDisplays = mDisplayContents.size();
             for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
                 final DisplayContent displayContent = mDisplayContents.valueAt(displayNdx);
-                TaskStack stack = displayContent.createStack(this, stackId, relativeStackBoxId,
-                        position, weight);
+                TaskStack stack = displayContent.createStack(stackId, relativeStackBoxId, position,
+                        weight);
                 if (stack != null) {
                     mStackIdToStack.put(stackId, stack);
                     displayContent.moveStack(stack, true);
@@ -10716,7 +10716,7 @@ public class WindowManagerService extends IWindowManager.Stub
     }
 
     private DisplayContent newDisplayContentLocked(final Display display) {
-        DisplayContent displayContent = new DisplayContent(display);
+        DisplayContent displayContent = new DisplayContent(display, this);
         final int displayId = display.getDisplayId();
         mDisplayContents.put(displayId, displayContent);
         final Rect rect = new Rect();