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

Commit 10a80e0b authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Fix windows disappearing when resizing freeform or docked.

Also includes some code clarity improvements: mHasSurface is set using a
setter, some fields get private.

Change-Id: I2f834880493c008fdccf07ff6ebfebd2e26690a9
parent 8382f98f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -8859,7 +8859,7 @@ public class WindowManagerService extends IWindowManager.Stub
                                    + " pid=" + ws.mSession.mPid
                                    + " uid=" + ws.mSession.mUid);
                            wsa.destroySurface();
                            ws.mHasSurface = false;
                            ws.setHasSurface(false);
                            mForceRemoves.add(ws);
                            leakedSurface = true;
                        } else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
@@ -8869,7 +8869,7 @@ public class WindowManagerService extends IWindowManager.Stub
                                    + " saved=" + ws.mAppToken.mHasSavedSurface);
                            if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
                            wsa.destroySurface();
                            ws.mHasSurface = false;
                            ws.setHasSurface(false);
                            ws.mAppToken.mHasSavedSurface = false;
                            leakedSurface = true;
                        }
@@ -8916,7 +8916,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) logSurface(winAnimator.mWin,
                            "RECOVER DESTROY", null);
                    surfaceController.destroyInTransaction();
                    winAnimator.mWin.mHasSurface = false;
                    winAnimator.mWin.setHasSurface(false);
                    scheduleRemoveStartingWindowLocked(winAnimator.mWin.mAppToken);
                }

+4 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,10 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        mConfigHasChanged = false;
    }

    void setHasSurface(boolean hasSurface) {
        mHasSurface = hasSurface;
    }

    private final class DeadWindowEventReceiver extends InputEventReceiver {
        DeadWindowEventReceiver(InputChannel inputChannel) {
            super(inputChannel, mService.mH.getLooper());
+13 −6
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class WindowStateAnimator {
     */
    boolean mSurfaceResized;
    WindowSurfaceController mSurfaceController;
    WindowSurfaceController mPendingDestroySurface;
    private WindowSurfaceController mPendingDestroySurface;

    /**
     * Set if the client has asked that the destroy of its surface be delayed
@@ -109,7 +109,7 @@ class WindowStateAnimator {
     */
    boolean mSurfaceDestroyDeferred;

    boolean mDestroyPreservedSurfaceUponRedraw;
    private boolean mDestroyPreservedSurfaceUponRedraw;
    float mShownAlpha = 0;
    float mAlpha = 0;
    float mLastAlpha = 0;
@@ -653,7 +653,7 @@ class WindowStateAnimator {
                        attrs.getTitle().toString(),
                        width, height, format, flags, this);

                w.mHasSurface = true;
                w.setHasSurface(true);

                if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
                    Slog.i(TAG, "  CREATE SURFACE "
@@ -665,13 +665,13 @@ class WindowStateAnimator {
                            + " / " + this);
                }
            } catch (OutOfResourcesException e) {
                w.mHasSurface = false;
                w.setHasSurface(false);
                Slog.w(TAG, "OutOfResourcesException creating surface");
                mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);
                mDrawState = NO_SURFACE;
                return null;
            } catch (Exception e) {
                w.mHasSurface = false;
                w.setHasSurface(false);
                Slog.e(TAG, "Exception creating surface", e);
                mDrawState = NO_SURFACE;
                return null;
@@ -758,7 +758,14 @@ class WindowStateAnimator {
                    + ": " + e.toString());
            }

            mWin.mHasSurface = false;
            // Whether the surface was preserved (and copied to mPendingDestroySurface) or not, it
            // needs to be cleared to match the WindowState.mHasSurface state. It is also necessary
            // so it can be recreated successfully in mPendingDestroySurface case.
            mWin.setHasSurface(false);
            if (mSurfaceController != null) {
                mSurfaceController.setShown(false);
            }
            mSurfaceController = null;
            mDrawState = NO_SURFACE;
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -364,6 +364,10 @@ class WindowSurfaceController {
        return mSurfaceShown;
    }

    void setShown(boolean surfaceShown) {
        mSurfaceShown = surfaceShown;
    }

    float getX() {
        return mSurfaceX;
    }