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

Commit b9a07c3e authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Fixed issue with IME window not been added to its window token

This looks like a coding error that has always existed. The window
was added to the display window list, but not to its window token.
The issue was exposed by the switch to using the window container
hierarchy since the window was not a child of the token it wasn't
showing up in the hierarchy.

Test: Run 'adb shell dumpsys window containers' and make use the
InputMethod window shows up in the print-out.

Change-Id: I43cb5d6b3f266c1be54dd27def4c13e1ef98a4fa
parent 219cadc3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1059,6 +1059,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mService.mWindowsChanged = true;
    }

    void addToWindowList(WindowState win, int index) {
        mWindows.add(index, win);
    }

    void addChildWindowToWindowList(WindowState win) {
        final WindowState parentWindow = win.getParentWindow();

+3 −18
Original line number Diff line number Diff line
@@ -1276,21 +1276,6 @@ public class WindowManagerService extends IWindowManager.Stub
        return -1;
    }

    private void addInputMethodWindowToListLocked(WindowState win) {
        int pos = findDesiredInputMethodWindowIndexLocked(true);
        if (pos >= 0) {
            if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(
                    TAG_WM, "Adding input method window " + win + " at " + pos);
            // TODO(multidisplay): IMEs are only supported on the default display.
            getDefaultWindowListLocked().add(pos, win);
            mWindowsChanged = true;
            moveInputMethodDialogsLocked(pos + 1);
            return;
        }
        win.mToken.addWindow(win);
        moveInputMethodDialogsLocked(pos);
    }

    private void reAddWindowToListInOrderLocked(WindowState win) {
        win.mToken.addWindow(win);
        // This is a hack to get all of the child windows added as well at the right position. Child
@@ -1305,7 +1290,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void logWindowList(final WindowList windows, String prefix) {
    private void logWindowList(final WindowList windows, String prefix) {
        int N = windows.size();
        while (N > 0) {
            N--;
@@ -1746,7 +1731,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (type == TYPE_INPUT_METHOD) {
                win.mGivenInsetsPending = true;
                mInputMethodWindow = win;
                addInputMethodWindowToListLocked(win);
                win.mToken.addImeWindow(win);
                imMayMove = false;
            } else if (type == TYPE_INPUT_METHOD_DIALOG) {
                mInputMethodDialogs.add(win);
@@ -1980,7 +1965,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    public void removeWindow(Session session, IWindow client) {
    void removeWindow(Session session, IWindow client) {
        synchronized(mWindowMap) {
            WindowState win = windowForClientLocked(session, client, false);
            if (win == null) {
+19 −0
Original line number Diff line number Diff line
@@ -193,6 +193,25 @@ class WindowToken extends WindowContainer<WindowState> {
        }
    }

    void addImeWindow(WindowState win) {
        int pos = mService.findDesiredInputMethodWindowIndexLocked(true);

        if (pos < 0) {
            addWindow(win);
            mService.moveInputMethodDialogsLocked(pos);
            return;
        }

        if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                "Adding input method window " + win + " at " + pos);
        mDisplayContent.addToWindowList(win, pos);
        if (!mChildren.contains(win)) {
            addChild(win, null);
        }
        mService.mWindowsChanged = true;
        mService.moveInputMethodDialogsLocked(pos + 1);
    }

    /** Return the first window in the token window list that isn't a starting window or null. */
    WindowState getFirstNonStartingWindow() {
        final int count = mChildren.size();