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

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

Have DisplayContent be the call point for assigning window layers

First step in trying to make the WindowList private to DisplayContent
Have the rest of the system call DisplayContent when they need to
assign layers to windows instead of calling WindowLayersController
directly. That way all the various call points don't need to get
the WindowList from DisplayContent to pass on to WindowLayersController.

Test: Existing tests pass.
Change-Id: If869abf7ba1c33b575908006ae5ad1557abc361c
parent c4ee093b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -425,8 +425,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
        if (destroyedSomething) {
            final DisplayContent dc = getDisplayContent();
            mService.mLayersController.assignLayersLocked(dc.getWindowList());
            dc.setLayoutNeeded();
            dc.assignWindowLayers(true /*setLayoutNeeded*/);
        }
    }

+40 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYERS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
@@ -171,13 +172,20 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    // the display's direct children should be allowed.
    private boolean mRemovingDisplay = false;

    private final WindowLayersController mLayersController;
    int mInputMethodAnimLayerAdjustment;

    /**
     * @param display May not be null.
     * @param service You know.
     * @param layersController window layer controller used to assign layer to the windows on this
     *                         display.
     */
    DisplayContent(Display display, WindowManagerService service) {
    DisplayContent(Display display, WindowManagerService service,
            WindowLayersController layersController) {
        mDisplay = display;
        mDisplayId = display.getDisplayId();
        mLayersController = layersController;
        display.getDisplayInfo(mDisplayInfo);
        display.getMetrics(mDisplayMetrics);
        isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
@@ -691,6 +699,24 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    void setInputMethodAnimLayerAdjustment(int adj) {
        if (DEBUG_LAYERS) Slog.v(TAG_WM, "Setting im layer adj to " + adj);
        mInputMethodAnimLayerAdjustment = adj;
        final WindowState imw = mService.mInputMethodWindow;
        if (imw != null) {
            imw.adjustAnimLayer(adj);
        }
        for (int i = mService.mInputMethodDialogs.size() - 1; i >= 0; i--) {
            final WindowState dialog = mService.mInputMethodDialogs.get(i);
            // TODO: This and other places setting mAnimLayer can probably use WS.adjustAnimLayer,
            // but need to make sure we are not setting things twice for child windows that are
            // already in the list.
            dialog.mWinAnimator.mAnimLayer = dialog.mLayer + adj;
            if (DEBUG_LAYERS) Slog.v(TAG_WM, "IM win " + imw
                    + " anim layer: " + dialog.mWinAnimator.mAnimLayer);
        }
    }

    void prepareFreezingTaskBounds() {
        for (int stackNdx = mTaskStackContainers.size() - 1; stackNdx >= 0; --stackNdx) {
            final TaskStack stack = mTaskStackContainers.get(stackNdx);
@@ -798,6 +824,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mDimLayerController.dump(prefix + "  ", pw);
        pw.println();
        mDividerControllerLocked.dump(prefix + "  ", pw);

        if (mInputMethodAnimLayerAdjustment != 0) {
            pw.println(subPrefix
                    + "mInputMethodAnimLayerAdjustment=" + mInputMethodAnimLayerAdjustment);
        }
    }

    @Override
@@ -1113,6 +1144,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    /** Updates the layer assignment of windows on this display. */
    void assignWindowLayers(boolean setLayoutNeeded) {
        mLayersController.assignWindowLayers(mWindows);
        if (setLayoutNeeded) {
            setLayoutNeeded();
        }
    }

    /**
     * Z-orders the display window list so that:
     * <ul>
+15 −7
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static com.android.server.wm.AppTransition.TRANSIT_NONE;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.H.NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED;
import static com.android.server.wm.WindowManagerService.LAYER_OFFSET_DIM;

import android.content.Context;
import android.content.res.Configuration;
@@ -296,7 +297,7 @@ public class DockedStackDividerController implements DimLayerUser {
        }
    }

    boolean wasVisible() {
    private boolean wasVisible() {
        return mLastVisibility;
    }

@@ -356,7 +357,7 @@ public class DockedStackDividerController implements DimLayerUser {
        mLastRect.set(frame);
    }

    void notifyDockedDividerVisibilityChanged(boolean visible) {
    private void notifyDockedDividerVisibilityChanged(boolean visible) {
        final int size = mDockedStackListeners.beginBroadcast();
        for (int i = 0; i < size; ++i) {
            final IDockedStackListener listener = mDockedStackListeners.getBroadcastItem(i);
@@ -413,7 +414,7 @@ public class DockedStackDividerController implements DimLayerUser {
        return mImeHideRequested;
    }

    void notifyDockedStackMinimizedChanged(boolean minimizedDock, long animDuration) {
    private void notifyDockedStackMinimizedChanged(boolean minimizedDock, long animDuration) {
        mService.mH.removeMessages(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED);
        mService.mH.obtainMessage(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED,
                minimizedDock ? 1 : 0, 0).sendToTarget();
@@ -442,7 +443,7 @@ public class DockedStackDividerController implements DimLayerUser {
        mDockedStackListeners.finishBroadcast();
    }

    void notifyAdjustedForImeChanged(boolean adjustedForIme, long animDuration) {
    private void notifyAdjustedForImeChanged(boolean adjustedForIme, long animDuration) {
        final int size = mDockedStackListeners.beginBroadcast();
        for (int i = 0; i < size; ++i) {
            final IDockedStackListener listener = mDockedStackListeners.getBroadcastItem(i);
@@ -474,8 +475,7 @@ public class DockedStackDividerController implements DimLayerUser {
            stack.getDimBounds(mTmpRect);
            if (mTmpRect.height() > 0 && mTmpRect.width() > 0) {
                mDimLayer.setBounds(mTmpRect);
                mDimLayer.show(mService.mLayersController.getResizeDimLayer(),
                        alpha, 0 /* duration */);
                mDimLayer.show(getResizeDimLayer(), alpha, 0 /* duration */);
            } else {
                visibleAndValid = false;
            }
@@ -486,6 +486,14 @@ public class DockedStackDividerController implements DimLayerUser {
        mService.closeSurfaceTransaction();
    }

    /**
     * @return The layer used for dimming the apps when dismissing docked/fullscreen stack. Just
     *         above all application surfaces.
     */
    private int getResizeDimLayer() {
        return (mWindow != null) ? mWindow.mLayer - 1 : LAYER_OFFSET_DIM;
    }

    /**
     * Notifies the docked stack divider controller of a visibility change that happens without
     * an animation.
@@ -693,7 +701,7 @@ public class DockedStackDividerController implements DimLayerUser {
            return animateForIme(now);
        } else {
            if (mDimLayer != null && mDimLayer.isDimming()) {
                mDimLayer.setLayer(mService.mLayersController.getResizeDimLayer());
                mDimLayer.setLayer(getResizeDimLayer());
            }
            return false;
        }
+8 −6
Original line number Diff line number Diff line
@@ -165,8 +165,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
    ParcelFileDescriptor mSurfaceTraceFd;
    RemoteEventTrace mRemoteEventTrace;

    private final WindowLayersController mLayersController;

    RootWindowContainer(WindowManagerService service) {
        mService = service;
        mLayersController = new WindowLayersController(mService);
    }

    WindowState computeFocusedWindow() {
@@ -211,7 +214,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
    }

    private DisplayContent createDisplayContent(final Display display) {
        final DisplayContent dc = new DisplayContent(display, mService);
        final DisplayContent dc = new DisplayContent(display, mService, mLayersController);
        final int displayId = display.getDisplayId();

        if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);
@@ -1171,9 +1174,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
                }
            }

            for (DisplayContent displayContent : displayList) {
                mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
                displayContent.setLayoutNeeded();
            for (int j = displayList.size() - 1; j >= 0; --j) {
                final DisplayContent dc = displayList.get(j);
                dc.assignWindowLayers(true /*setLayoutNeeded*/);
            }
        }

@@ -1250,8 +1253,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {

                if ((dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0
                        && mService.mWallpaperControllerLocked.adjustWallpaperWindows()) {
                    mService.mLayersController.assignLayersLocked(windows);
                    dc.setLayoutNeeded();
                    dc.assignWindowLayers(true /*setLayoutNeeded*/);
                }

                if (isDefaultDisplay
+5 −2
Original line number Diff line number Diff line
@@ -742,8 +742,7 @@ class WallpaperController {
        }

        if (adjust && adjustWallpaperWindows()) {
            mService.mLayersController.assignLayersLocked(windows);
            dc.setLayoutNeeded();
            dc.assignWindowLayers(true /*setLayoutNeeded*/);
        }
    }

@@ -769,6 +768,10 @@ class WallpaperController {
            pw.print("mLastWallpaperDisplayOffsetX="); pw.print(mLastWallpaperDisplayOffsetX);
            pw.print(" mLastWallpaperDisplayOffsetY="); pw.println(mLastWallpaperDisplayOffsetY);
        }

        if (mWallpaperAnimLayerAdjustment != 0) {
            pw.println(prefix + "mWallpaperAnimLayerAdjustment=" + mWallpaperAnimLayerAdjustment);
        }
    }

    void dumpTokens(PrintWriter pw, String prefix, boolean dumpAll) {
Loading