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

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

Added RootWindowContainer

RootWindowContainer will be the root/head of the window hierarchy.
Also, moved all access of DisplayContent into RootWindowContainer.

Bug: 30060889
Test: Manual testing and existing tests still pass.
Change-Id: Icdf80a4c053578fb91221e6f2b672e197054a6bf
parent 7b3aaf63
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1055,7 +1055,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree

    @Override
    void updateAllDrawn(int displayId) {
        final DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
        final DisplayContent displayContent = mService.mRoot.getDisplayContent(displayId);

        if (!allDrawn) {
            final int numInteresting = numInterestingWindows;
+3 −2
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ class DisplayContent extends WindowContainer<TaskStack> {
        }
    }

    void switchUserStacks() {
    void switchUser() {
        final WindowList windows = getWindowList();
        for (int i = 0; i < windows.size(); i++) {
            final WindowState win = windows.get(i);
@@ -485,7 +485,8 @@ class DisplayContent extends WindowContainer<TaskStack> {
    void removeImmediately() {
        super.removeImmediately();
        if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this);
        mService.mDisplayContents.delete(mDisplayId);
        // TODO: remove this line once RootWindowContainer is online.
        mService.mRoot.mDisplayContents.delete(mDisplayId);
        mDimLayerController.close();
        if (mDisplayId == Display.DEFAULT_DISPLAY) {
            mService.unregisterPointerEventListener(mTapDetector);
+7 −71
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        return 0; // abort dispatching
    }

    private void addInputWindowHandleLw(final InputWindowHandle windowHandle) {
    void addInputWindowHandle(final InputWindowHandle windowHandle) {
        if (mInputWindowHandles == null) {
            mInputWindowHandles = new InputWindowHandle[16];
        }
@@ -176,7 +176,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        mInputWindowHandles[mInputWindowHandleCount++] = windowHandle;
    }

    private void addInputWindowHandleLw(final InputWindowHandle inputWindowHandle,
    void addInputWindowHandle(final InputWindowHandle inputWindowHandle,
            final WindowState child, int flags, final int type, final boolean isVisible,
            final boolean hasFocus, final boolean hasWallpaper) {
        // Add a window to our list of input windows.
@@ -214,7 +214,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
            Slog.d(TAG_WM, "addInputWindowHandle: "
                    + child + ", " + inputWindowHandle);
        }
        addInputWindowHandleLw(inputWindowHandle);
        addInputWindowHandle(inputWindowHandle);
    }

    private void clearInputWindowHandlesLw() {
@@ -241,9 +241,8 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        // As an optimization, we could try to prune the list of windows but this turns
        // out to be difficult because only the native code knows for sure which window
        // currently has touch focus.
        boolean disableWallpaperTouchEvents = false;

        // If there's a drag in flight, provide a pseudowindow to catch drag input
        // If there's a drag in flight, provide a pseudo-window to catch drag input
        final boolean inDrag = (mService.mDragState != null);
        if (inDrag) {
            if (DEBUG_DRAG) {
@@ -251,7 +250,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
            }
            final InputWindowHandle dragWindowHandle = mService.mDragState.getInputWindowHandle();
            if (dragWindowHandle != null) {
                addInputWindowHandleLw(dragWindowHandle);
                addInputWindowHandle(dragWindowHandle);
            } else {
                Slog.w(TAG_WM, "Drag is in progress but there is no "
                        + "drag window handle.");
@@ -265,78 +264,15 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
            }
            final InputWindowHandle dragWindowHandle = mService.mTaskPositioner.mDragWindowHandle;
            if (dragWindowHandle != null) {
                addInputWindowHandleLw(dragWindowHandle);
                addInputWindowHandle(dragWindowHandle);
            } else {
                Slog.e(TAG_WM,
                        "Repositioning is in progress but there is no drag window handle.");
            }
        }

        boolean addInputConsumerHandle = mService.mInputConsumer != null;

        boolean addWallpaperInputConsumerHandle = mService.mWallpaperInputConsumer != null;

        // Add all windows on the default display.
        final int numDisplays = mService.mDisplayContents.size();
        final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
        for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
            final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
            final WindowList windows = displayContent.getWindowList();
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState child = windows.get(winNdx);
                final InputChannel inputChannel = child.mInputChannel;
                final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
                if (inputChannel == null || inputWindowHandle == null || child.mRemoved
                        || child.isAdjustedForMinimizedDock()) {
                    // Skip this window because it cannot possibly receive input.
                    continue;
                }
                if (addInputConsumerHandle
                        && inputWindowHandle.layer <= mService.mInputConsumer.mWindowHandle.layer) {
                    addInputWindowHandleLw(mService.mInputConsumer.mWindowHandle);
                    addInputConsumerHandle = false;
                }

                if (addWallpaperInputConsumerHandle) {
                    if (child.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER &&
                            child.isVisibleLw()) {
                        // Add the wallpaper input consumer above the first visible wallpaper.
                        addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
                        addWallpaperInputConsumerHandle = false;
                    }
                }

                final int flags = child.mAttrs.flags;
                final int privateFlags = child.mAttrs.privateFlags;
                final int type = child.mAttrs.type;

                final boolean hasFocus = (child == mInputFocus);
                final boolean isVisible = child.isVisibleLw();
                if ((privateFlags
                        & WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS)
                            != 0) {
                    disableWallpaperTouchEvents = true;
                }
                final boolean hasWallpaper = wallpaperController.isWallpaperTarget(child)
                        && (privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD) == 0
                        && !disableWallpaperTouchEvents;
                final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);

                // If there's a drag in progress and 'child' is a potential drop target,
                // make sure it's been told about the drag
                if (inDrag && isVisible && onDefaultDisplay) {
                    mService.mDragState.sendDragStartedIfNeededLw(child);
                }

                addInputWindowHandleLw(
                        inputWindowHandle, child, flags, type, isVisible, hasFocus, hasWallpaper);
            }
        }

        if (addWallpaperInputConsumerHandle) {
            // No visible wallpaper found, add the wallpaper input consumer at the end.
            addInputWindowHandleLw(mService.mWallpaperInputConsumer.mWindowHandle);
        }
        mService.mRoot.updateInputWindows(this, mInputFocus, inDrag);

        // Send windows to native code.
        mService.mInputManager.setInputWindows(mInputWindowHandles);
+1419 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -641,7 +641,7 @@ class WallpaperController {
    }

    boolean adjustWallpaperWindows() {
        mService.mWindowPlacerLocked.mWallpaperMayChange = false;
        mService.mRoot.mWallpaperMayChange = false;

        final WindowList windows = mService.getDefaultWindowListLocked();
        // First find top-most window that has asked to be on top of the wallpaper;
Loading