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

Commit 2033763b authored by Jeff Brown's avatar Jeff Brown
Browse files

Allow a window on a secondary display to have focus.

If any window on the default display has focus, then it
gets focus as usual.  If no window on the default display
has focus, then we consider windows on the secondary display.

In the future we will need more elaborate schemes for
managing focus across multiple displays, but this is enough
for testing purposes now.

Bug: 7183618
Change-Id: I21ddb9904eb9e574e42d28743aeca51f4ffebf64
parent efd43bdb
Loading
Loading
Loading
Loading
+19 −14
Original line number Original line Diff line number Diff line
@@ -9777,7 +9777,7 @@ public class WindowManagerService extends IWindowManager.Stub
                if (moveInputMethodWindowsIfNeededLocked(
                if (moveInputMethodWindowsIfNeededLocked(
                        mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS &&
                        mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS &&
                        mode != UPDATE_FOCUS_WILL_PLACE_SURFACES)) {
                        mode != UPDATE_FOCUS_WILL_PLACE_SURFACES)) {
                    getDefaultDisplayContentLocked().layoutNeeded = true;
                    displayContent.layoutNeeded = true;
                }
                }
                if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                    performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
                    performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
@@ -9791,7 +9791,7 @@ public class WindowManagerService extends IWindowManager.Stub


            if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
            if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
                // The change in focus caused us to need to do a layout.  Okay.
                // The change in focus caused us to need to do a layout.  Okay.
                getDefaultDisplayContentLocked().layoutNeeded = true;
                displayContent.layoutNeeded = true;
                if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                    performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
                    performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
                }
                }
@@ -9814,22 +9814,29 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    private WindowState computeFocusedWindowLocked() {
    private WindowState computeFocusedWindowLocked() {
        WindowState result = null;
        WindowState win;

        if (mAnimator.mUniverseBackground != null
        if (mAnimator.mUniverseBackground != null
                && mAnimator.mUniverseBackground.mWin.canReceiveKeys()) {
                && mAnimator.mUniverseBackground.mWin.canReceiveKeys()) {
            return mAnimator.mUniverseBackground.mWin;
            return mAnimator.mUniverseBackground.mWin;
        }
        }


        final int displayCount = mDisplayContents.size();
        for (int i = 0; i < displayCount; i++) {
            final DisplayContent displayContent = mDisplayContents.valueAt(i);
            WindowState win = findFocusedWindowLocked(displayContent);
            if (win != null) {
                return win;
            }
        }
        return null;
    }

    private WindowState findFocusedWindowLocked(DisplayContent displayContent) {
        int nextAppIndex = mAppTokens.size()-1;
        int nextAppIndex = mAppTokens.size()-1;
        WindowToken nextApp = nextAppIndex >= 0
        WindowToken nextApp = nextAppIndex >= 0 ? mAppTokens.get(nextAppIndex) : null;
            ? mAppTokens.get(nextAppIndex) : null;


        // TODO(multidisplay): IMEs are only supported on the default display.
        final WindowList windows = displayContent.getWindowList();
        WindowList windows = getDefaultWindowListLocked();
        for (int i = windows.size() - 1; i >= 0; i--) {
        for (int i = windows.size() - 1; i >= 0; i--) {
            win = windows.get(i);
            final WindowState win = windows.get(i);


            if (localLOGV || DEBUG_FOCUS) Slog.v(
            if (localLOGV || DEBUG_FOCUS) Slog.v(
                TAG, "Looking for focus: " + i
                TAG, "Looking for focus: " + i
@@ -9879,12 +9886,10 @@ public class WindowManagerService extends IWindowManager.Stub
            if (win.canReceiveKeys()) {
            if (win.canReceiveKeys()) {
                if (DEBUG_FOCUS) Slog.v(
                if (DEBUG_FOCUS) Slog.v(
                        TAG, "Found focus @ " + i + " = " + win);
                        TAG, "Found focus @ " + i + " = " + win);
                result = win;
                return win;
                break;
            }
            }
        }
        }

        return null;
        return result;
    }
    }


    private void startFreezingDisplayLocked(boolean inTransaction,
    private void startFreezingDisplayLocked(boolean inTransaction,