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

Commit da61ba9d authored by Robert Carr's avatar Robert Carr
Browse files

Change layer stack when moving displays.

Previously we only change layer stack when creating a new surface.
This isn't enough for moving existing activities between displays.

Test: Try moving existing activity to new display.
Bug: 36002411
Change-Id: I536f26cba43fc4fd1b60c8b504355076e2fb162e
parent 834c260e
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -591,6 +591,17 @@ class WindowStateAnimator {
        }
    }

    private int getLayerStack() {
        return mWin.getDisplayContent().getDisplay().getLayerStack();
    }

    void updateLayerStackInTransaction() {
        if (mSurfaceController != null) {
            mSurfaceController.setLayerStackInTransaction(
                    getLayerStack());
        }
    }

    WindowSurfaceController createSurfaceLocked(int windowType, int ownerUid) {
        final WindowState w = mWin;
        if (w.restoreSavedSurface()) {
@@ -703,8 +714,7 @@ class WindowStateAnimator {
        }

        // Start a new transaction and apply position & offset.
        final int layerStack = w.getDisplayContent().getDisplay().getLayerStack();
        mSurfaceController.setPositionAndLayer(mTmpSize.left, mTmpSize.top, layerStack, mAnimLayer);
        mSurfaceController.setPositionAndLayer(mTmpSize.left, mTmpSize.top, getLayerStack(), mAnimLayer);
        mLastHidden = true;

        if (WindowManagerService.localLOGV) Slog.v(TAG, "Created surface " + this);
@@ -1435,7 +1445,6 @@ class WindowStateAnimator {
                    WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
            w.applyDimLayerIfNeeded();
        }

    }

    void prepareSurfaceLocked(final boolean recoveringMemory) {
+8 −2
Original line number Diff line number Diff line
@@ -276,6 +276,12 @@ class WindowSurfaceController {
        }
    }

    void setLayerStackInTransaction(int layerStack) {
        if (mSurfaceControl != null) {
            mSurfaceControl.setLayerStack(layerStack);
        }
    }

    void setPositionInTransaction(float left, float top, boolean recoveringMemory) {
        final boolean surfaceMoved = mSurfaceX != left || mSurfaceY != top;
        if (surfaceMoved) {
@@ -357,7 +363,8 @@ class WindowSurfaceController {
        return false;
    }

    boolean prepareToShowInTransaction(float alpha, int layer, float dsdx, float dtdx, float dsdy,
    boolean prepareToShowInTransaction(float alpha, int layer,
            float dsdx, float dtdx, float dsdy,
            float dtdy, boolean recoveringMemory) {
        if (mSurfaceControl != null) {
            try {
@@ -371,7 +378,6 @@ class WindowSurfaceController {
                mLastDtdy = dtdy;
                mSurfaceControl.setMatrix(
                        dsdx, dtdx, dsdy, dtdy);

            } catch (RuntimeException e) {
                Slog.w(TAG, "Error updating surface in " + title, e);
                if (!recoveringMemory) {
+13 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import android.os.Debug;
import android.os.IBinder;
import android.util.Slog;
import android.view.SurfaceControl;

import java.io.PrintWriter;

@@ -245,6 +246,18 @@ class WindowToken extends WindowContainer<WindowState> {
    void onDisplayChanged(DisplayContent dc) {
        dc.reParentWindowToken(this);
        mDisplayContent = dc;

        // TODO(b/36740756): One day this should perhaps be hooked
        // up with goodToGo, so we don't move a window
        // to another display before the window behind
        // it is ready.
        SurfaceControl.openTransaction();
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowState win = mChildren.get(i);
            win.mWinAnimator.updateLayerStackInTransaction();
        }
        SurfaceControl.closeTransaction();

        super.onDisplayChanged(dc);
    }