Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efb735db authored by Craig Mautner's avatar Craig Mautner
Browse files

Fix incorrect indexing calculation.

Fixes bug 7129583.

Change-Id: Ia395a7acded05686668d5b3cee09d49025a9f339
parent c0be8c85
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -887,6 +887,12 @@ public class WindowManagerService extends IWindowManager.Stub
        return -1;
    }

    /**
     * Return the list of Windows from the passed token on the given Display.
     * @param token The token with all the windows.
     * @param displayContent The display we are interested in.
     * @return List of windows from token that are on displayContent.
     */
    WindowList getTokenWindowsOnDisplay(WindowToken token, DisplayContent displayContent) {
        final WindowList windowList = new WindowList();
        final int count = token.windows.size();
@@ -928,7 +934,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        WindowState lastWindow = tokenWindowList.get(index);
                        if (atoken != null && lastWindow == atoken.startingWindow) {
                            placeWindowBefore(lastWindow, win);
                            tokenWindowsPos = token.windows.indexOf(lastWindow) - 1;
                            tokenWindowsPos = token.windows.indexOf(lastWindow);
                        } else {
                            int newIdx = findIdxBasedOnAppTokens(win);
                            //there is a window above this one associated with the same
@@ -940,7 +946,12 @@ public class WindowManagerService extends IWindowManager.Stub
                                        + (newIdx + 1) + " of " + N);
                            }
                            windows.add(newIdx + 1, win);
                            if (newIdx < 0) {
                                // No window from token found on win's display.
                                tokenWindowsPos = 0;
                            } else {
                                tokenWindowsPos = token.windows.indexOf(windows.get(newIdx)) + 1;
                            }
                            mWindowsChanged = true;
                        }
                    }