summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-11-30 16:14:45 -0800
committerCraig Mautner <cmautner@google.com>2012-11-30 16:14:45 -0800
commit7b1aa77a9b25b4b1e8070c9cccfadcde39954952 (patch)
treed76efb533bc54fa9eccdebc0fa73fda25e08c369 /services
parentb1a01ab01c2aa5136f7781c3a6ec682590e38ac4 (diff)
downloadframeworks_base-7b1aa77a9b25b4b1e8070c9cccfadcde39954952.zip
frameworks_base-7b1aa77a9b25b4b1e8070c9cccfadcde39954952.tar.gz
frameworks_base-7b1aa77a9b25b4b1e8070c9cccfadcde39954952.tar.bz2
Include child windows when looking for insertion point.
After finding a window in the window list we turn around and look in the AppWindowToken.windows list for it. If it is a child of a window in that list we should use the parent windows index as the search result. Instead we gave up and ended up inserting the window at the beginning of the windows list. Bug 7357465 fixed. Change-Id: If77f343b8597bfbb0b7fa41dedf7972d78d03020
Diffstat (limited to 'services')
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java28
-rw-r--r--services/java/com/android/server/wm/WindowState.java2
-rw-r--r--services/java/com/android/server/wm/WindowToken.java2
3 files changed, 27 insertions, 5 deletions
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index d0ab917..9ba83d0 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -919,6 +919,27 @@ public class WindowManagerService extends IWindowManager.Stub
return windowList;
}
+ /**
+ * Recursive search through a WindowList and all of its windows' children.
+ * @param targetWin The window to search for.
+ * @param windows The list to search.
+ * @return The index of win in windows or of the window that is an ancestor of win.
+ */
+ private int indexOfWinInWindowList(WindowState targetWin, WindowList windows) {
+ for (int i = windows.size() - 1; i >= 0; i--) {
+ final WindowState w = windows.get(i);
+ if (w == targetWin) {
+ return i;
+ }
+ if (!w.mChildWindows.isEmpty()) {
+ if (indexOfWinInWindowList(targetWin, w.mChildWindows) >= 0) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
private void addWindowToListInOrderLocked(WindowState win, boolean addToToken) {
final IWindow client = win.mClient;
final WindowToken token = win.mToken;
@@ -942,13 +963,13 @@ public class WindowManagerService extends IWindowManager.Stub
// Base windows go behind everything else.
WindowState lowestWindow = tokenWindowList.get(0);
placeWindowBefore(lowestWindow, win);
- tokenWindowsPos = token.windows.indexOf(lowestWindow);
+ tokenWindowsPos = indexOfWinInWindowList(lowestWindow, token.windows);
} else {
AppWindowToken atoken = win.mAppToken;
WindowState lastWindow = tokenWindowList.get(index);
if (atoken != null && lastWindow == atoken.startingWindow) {
placeWindowBefore(lastWindow, win);
- tokenWindowsPos = token.windows.indexOf(lastWindow);
+ tokenWindowsPos = indexOfWinInWindowList(lastWindow, token.windows);
} else {
int newIdx = findIdxBasedOnAppTokens(win);
//there is a window above this one associated with the same
@@ -964,7 +985,8 @@ public class WindowManagerService extends IWindowManager.Stub
// No window from token found on win's display.
tokenWindowsPos = 0;
} else {
- tokenWindowsPos = token.windows.indexOf(windows.get(newIdx)) + 1;
+ tokenWindowsPos = indexOfWinInWindowList(
+ windows.get(newIdx), token.windows) + 1;
}
mWindowsChanged = true;
}
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 3dce939..81eac20 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -79,7 +79,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
final DeathRecipient mDeathRecipient;
final WindowState mAttachedWindow;
- final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
+ final WindowList mChildWindows = new WindowList();
final int mBaseLayer;
final int mSubLayer;
final boolean mLayoutAttached;
diff --git a/services/java/com/android/server/wm/WindowToken.java b/services/java/com/android/server/wm/WindowToken.java
index e581915..bd0ace8 100644
--- a/services/java/com/android/server/wm/WindowToken.java
+++ b/services/java/com/android/server/wm/WindowToken.java
@@ -48,7 +48,7 @@ class WindowToken {
AppWindowToken appWindowToken;
// All of the windows associated with this token.
- final ArrayList<WindowState> windows = new ArrayList<WindowState>();
+ final WindowList windows = new WindowList();
// Is key dispatching paused for this token?
boolean paused = false;