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

Commit e2a98a74 authored by tiger_huang's avatar tiger_huang
Browse files

Add window to child window list with correct order

The original logic of comparing with mBaseLayer of two child windows
of the same parent was wrong, because the mBaseLayer is always the
same.

After adding two child windows with the same positive sublayer, the
one added later should have greater z-order. The order should be
consistent with WindowManagerService.addAttachedWindowToListLocked()

Change-Id: I789179aee61d141fad86bd24262fabfb1e517e66
parent 71f83672
Loading
Loading
Loading
Loading
+16 −18
Original line number Original line Diff line number Diff line
@@ -386,28 +386,26 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            mAttachedWindow = attachedWindow;
            mAttachedWindow = attachedWindow;
            if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
            if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);


            int children_size = mAttachedWindow.mChildWindows.size();
            final WindowList childWindows = mAttachedWindow.mChildWindows;
            if (children_size == 0) {
            final int numChildWindows = childWindows.size();
                mAttachedWindow.mChildWindows.add(this);
            if (numChildWindows == 0) {
                childWindows.add(this);
            } else {
            } else {
                for (int i = 0; i < children_size; i++) {
                boolean added = false;
                    WindowState child = (WindowState)mAttachedWindow.mChildWindows.get(i);
                for (int i = 0; i < numChildWindows; i++) {
                    if (this.mSubLayer < child.mSubLayer) {
                    final int childSubLayer = childWindows.get(i).mSubLayer;
                        mAttachedWindow.mChildWindows.add(i, this);
                    if (mSubLayer < childSubLayer
                            || (mSubLayer == childSubLayer && childSubLayer < 0)) {
                        // We insert the child window into the list ordered by the sub-layer. For
                        // same sub-layers, the negative one should go below others; the positive
                        // one should go above others.
                        childWindows.add(i, this);
                        added = true;
                        break;
                        break;
                    } else if (this.mSubLayer > child.mSubLayer) {
                        continue;
                    }

                    if (this.mBaseLayer <= child.mBaseLayer) {
                        mAttachedWindow.mChildWindows.add(i, this);
                        break;
                    } else {
                        continue;
                    }
                    }
                }
                }
                if (children_size == mAttachedWindow.mChildWindows.size()) {
                if (!added) {
                    mAttachedWindow.mChildWindows.add(this);
                    childWindows.add(this);
                }
                }
            }
            }