Search in sources :

Example 6 with IWindow

use of android.view.IWindow in project android_frameworks_base by ResurrectionRemix.

the class WindowManagerService method addAppWindowToListLocked.

private int addAppWindowToListLocked(final WindowState win) {
    final DisplayContent displayContent = win.getDisplayContent();
    if (displayContent == null) {
        // It doesn't matter this display is going away.
        return 0;
    }
    final IWindow client = win.mClient;
    final WindowToken token = win.mToken;
    final WindowList windows = displayContent.getWindowList();
    WindowList tokenWindowList = getTokenWindowsOnDisplay(token, displayContent);
    int tokenWindowsPos = 0;
    if (!tokenWindowList.isEmpty()) {
        return addAppWindowToTokenListLocked(win, token, windows, tokenWindowList);
    }
    // No windows from this token on this display
    if (localLOGV)
        Slog.v(TAG_WM, "Figuring out where to add app window " + client.asBinder() + " (token=" + token + ")");
    // Figure out where the window should go, based on the
    // order of applications.
    WindowState pos = null;
    final ArrayList<Task> tasks = displayContent.getTasks();
    int taskNdx;
    int tokenNdx = -1;
    for (taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
        AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
        for (tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
            final AppWindowToken t = tokens.get(tokenNdx);
            if (t == token) {
                --tokenNdx;
                if (tokenNdx < 0) {
                    --taskNdx;
                    if (taskNdx >= 0) {
                        tokenNdx = tasks.get(taskNdx).mAppTokens.size() - 1;
                    }
                }
                break;
            }
            // We haven't reached the token yet; if this token
            // is not going to the bottom and has windows on this display, we can
            // use it as an anchor for when we do reach the token.
            tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
            if (!t.sendingToBottom && tokenWindowList.size() > 0) {
                pos = tokenWindowList.get(0);
            }
        }
        if (tokenNdx >= 0) {
            // early exit
            break;
        }
    }
    // we need to look some more.
    if (pos != null) {
        // Move behind any windows attached to this one.
        WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
        if (atoken != null) {
            tokenWindowList = getTokenWindowsOnDisplay(atoken, displayContent);
            final int NC = tokenWindowList.size();
            if (NC > 0) {
                WindowState bottom = tokenWindowList.get(0);
                if (bottom.mSubLayer < 0) {
                    pos = bottom;
                }
            }
        }
        placeWindowBefore(pos, win);
        return tokenWindowsPos;
    }
    // token that has windows on this display.
    for (; taskNdx >= 0; --taskNdx) {
        AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
        for (; tokenNdx >= 0; --tokenNdx) {
            final AppWindowToken t = tokens.get(tokenNdx);
            tokenWindowList = getTokenWindowsOnDisplay(t, displayContent);
            final int NW = tokenWindowList.size();
            if (NW > 0) {
                pos = tokenWindowList.get(NW - 1);
                break;
            }
        }
        if (tokenNdx >= 0) {
            // found
            break;
        }
    }
    if (pos != null) {
        // Move in front of any windows attached to this
        // one.
        WindowToken atoken = mTokenMap.get(pos.mClient.asBinder());
        if (atoken != null) {
            final int NC = atoken.windows.size();
            if (NC > 0) {
                WindowState top = atoken.windows.get(NC - 1);
                if (top.mSubLayer >= 0) {
                    pos = top;
                }
            }
        }
        placeWindowAfter(pos, win);
        return tokenWindowsPos;
    }
    // Just search for the start of this layer.
    final int myLayer = win.mBaseLayer;
    int i;
    for (i = windows.size() - 1; i >= 0; --i) {
        WindowState w = windows.get(i);
        // of the animation.
        if (w.mBaseLayer <= myLayer && w.mAttrs.type != TYPE_DOCK_DIVIDER) {
            break;
        }
    }
    if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE)
        Slog.v(TAG_WM, "Based on layer: Adding window " + win + " at " + (i + 1) + " of " + windows.size());
    windows.add(i + 1, win);
    mWindowsChanged = true;
    return tokenWindowsPos;
}
Also used : IWindow(android.view.IWindow) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)6 IWindow (android.view.IWindow)6 Configuration (android.content.res.Configuration)1 Rect (android.graphics.Rect)1 RemoteException (android.os.RemoteException)1 DisplayInfo (android.view.DisplayInfo)1 Animation (android.view.animation.Animation)1