summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortiger_huang <tiger_huang@htc.com>2014-11-13 19:46:28 +0800
committertiger_huang <tiger_huang@htc.com>2014-11-20 12:00:41 +0800
commite2a98a7492a44170f70f4d564372b5ac97090c21 (patch)
treeffb3b8765548de96274795f978103b41e3798a19
parent71f83672f297b116988defbe989869e5744cda5e (diff)
downloadframeworks_base-e2a98a7492a44170f70f4d564372b5ac97090c21.zip
frameworks_base-e2a98a7492a44170f70f4d564372b5ac97090c21.tar.gz
frameworks_base-e2a98a7492a44170f70f4d564372b5ac97090c21.tar.bz2
Add window to child window list with correct order
The original logic of comparing with mBaseLayer of two child windows of the same parent was wrong, because the mBaseLayer is always the same. After adding two child windows with the same positive sublayer, the one added later should have greater z-order. The order should be consistent with WindowManagerService.addAttachedWindowToListLocked() Change-Id: I789179aee61d141fad86bd24262fabfb1e517e66
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java34
1 files changed, 16 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index b4a7f04..04dab3e 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -386,28 +386,26 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mAttachedWindow = attachedWindow;
if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
- int children_size = mAttachedWindow.mChildWindows.size();
- if (children_size == 0) {
- mAttachedWindow.mChildWindows.add(this);
+ final WindowList childWindows = mAttachedWindow.mChildWindows;
+ final int numChildWindows = childWindows.size();
+ if (numChildWindows == 0) {
+ childWindows.add(this);
} else {
- for (int i = 0; i < children_size; i++) {
- WindowState child = (WindowState)mAttachedWindow.mChildWindows.get(i);
- if (this.mSubLayer < child.mSubLayer) {
- mAttachedWindow.mChildWindows.add(i, this);
+ boolean added = false;
+ for (int i = 0; i < numChildWindows; i++) {
+ final int childSubLayer = childWindows.get(i).mSubLayer;
+ if (mSubLayer < childSubLayer
+ || (mSubLayer == childSubLayer && childSubLayer < 0)) {
+ // We insert the child window into the list ordered by the sub-layer. For
+ // same sub-layers, the negative one should go below others; the positive
+ // one should go above others.
+ childWindows.add(i, this);
+ added = true;
break;
- } else if (this.mSubLayer > child.mSubLayer) {
- continue;
- }
-
- if (this.mBaseLayer <= child.mBaseLayer) {
- mAttachedWindow.mChildWindows.add(i, this);
- break;
- } else {
- continue;
}
}
- if (children_size == mAttachedWindow.mChildWindows.size()) {
- mAttachedWindow.mChildWindows.add(this);
+ if (!added) {
+ childWindows.add(this);
}
}