From 187350915315ded09fd97164bd7e8882e7aaefb3 Mon Sep 17 00:00:00 2001 From: "takeda.masayuki" Date: Wed, 12 Dec 2012 11:06:24 +0900 Subject: [PATCH] The order of child windows is switched By calling WindowManagerService#reAddWindowLocked(), the window object in DisplayContent.mWindows is rearranged. If this window has children, the window objects belonging to WindowState.mChildWindows are also rearranged together. At this time, while DisplayContent.mWindows is arranged in ascending order of Z-Order, WindowState.mChildWindows is arranged in descending order. Therefore, if children (= WindowState.mChildWindows) are added to DisplayContent.mWindows in the original order, the order of children is switched. I think that children must be sorted before they are added. Change-Id: I28a506f17fcd99c801a3faa17cca66fffb291596 --- .../com/android/server/wm/WindowState.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 81eac20cb11ed..e81486279e99e 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -314,7 +314,32 @@ final class WindowState implements WindowManagerPolicy.WindowState { mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); mAttachedWindow = attachedWindow; if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); - mAttachedWindow.mChildWindows.add(this); + + int children_size = mAttachedWindow.mChildWindows.size(); + if (children_size == 0) { + mAttachedWindow.mChildWindows.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); + 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); + } + } + mLayoutAttached = mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD