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

Commit f3d2e1fd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Apply show or hide transaction for InputSurface immediately"

parents c5f31108 f80c6a3f
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -73,17 +73,6 @@ class DragDropController {
        return mDragState != null && !mDragState.isClosing();
    }

    void showInputSurface(SurfaceControl.Transaction t, int displayId) {
        mDragState.showInputSurface(t, displayId);
    }

    void hideInputSurface(SurfaceControl.Transaction t, int displayId) {
        if (mDragState != null) {
            // TODO: Are we guaranteed to get here?
            mDragState.hideInputSurface(t, displayId);
        }
    }

    void registerCallback(IDragDropCallback callback) {
        Preconditions.checkNotNull(callback);
        mCallback.set(callback);
+18 −22
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class DragState {
    // A surface used to catch input events for the drag-and-drop operation.
    SurfaceControl mInputSurface;

    private final SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction();
    private final SurfaceControl.Transaction mTransaction;

    private final Rect mTmpClipRect = new Rect();

@@ -140,31 +140,24 @@ class DragState {
        mFlags = flags;
        mLocalWin = localWin;
        mNotifiedWindows = new ArrayList<WindowState>();

        mTransaction = service.mTransactionFactory.make();
    }

    boolean isClosing() {
        return mIsClosing;
    }

    void hideInputSurface(SurfaceControl.Transaction t, int displayId) {
        if (displayId != mDisplayContent.getDisplayId()) {
            return;
        }

    private void hideInputSurface() {
        if (mInputSurface != null) {
            t.hide(mInputSurface);
            mTransaction.hide(mInputSurface).apply();
        }
    }

    void showInputSurface(SurfaceControl.Transaction t, int displayId) {
        if (displayId != mDisplayContent.getDisplayId()) {
            return;
        }

    private void showInputSurface() {
        if (mInputSurface == null) {
            mInputSurface = mService.makeSurfaceBuilder(mService.mRoot.getDisplayContent(displayId)
                    .getSession()).setContainerLayer()
            mInputSurface = mService.makeSurfaceBuilder(
                    mService.mRoot.getDisplayContent(mDisplayContent.getDisplayId()).getSession())
                    .setContainerLayer()
                    .setName("Drag and Drop Input Consumer").build();
        }
        final InputWindowHandle h = getInputWindowHandle();
@@ -174,14 +167,16 @@ class DragState {
            return;
        }

        t.show(mInputSurface);
        t.setInputWindowInfo(mInputSurface, h);
        t.setLayer(mInputSurface, Integer.MAX_VALUE);
        mTransaction.show(mInputSurface);
        mTransaction.setInputWindowInfo(mInputSurface, h);
        mTransaction.setLayer(mInputSurface, Integer.MAX_VALUE);

        mTmpClipRect.set(0, 0, mDisplaySize.x, mDisplaySize.y);
        t.setWindowCrop(mInputSurface, mTmpClipRect);
        t.transferTouchFocus(mTransferTouchFromToken, h.token);
        mTransaction.setWindowCrop(mInputSurface, mTmpClipRect);
        mTransaction.transferTouchFocus(mTransferTouchFromToken, h.token);
        mTransferTouchFromToken = null;

        mTransaction.apply();
    }

    /**
@@ -199,9 +194,10 @@ class DragState {
            mDragDropController.sendHandlerMessage(
                    MSG_TEAR_DOWN_DRAG_AND_DROP_INPUT, mInputInterceptor);
            mInputInterceptor = null;
            mDisplayContent.getInputMonitor().updateInputWindowsLw(true /*force*/);
        }

        hideInputSurface();

        // Send drag end broadcast if drag start has been sent.
        if (mDragInProgress) {
            final int myPid = Process.myPid();
@@ -352,7 +348,7 @@ class DragState {
            Slog.e(TAG_WM, "Duplicate register of drag input channel");
        } else {
            mInputInterceptor = new InputInterceptor(display);
            mDisplayContent.getInputMonitor().updateInputWindowsLw(true /*force*/);
            showInputSurface();
        }
    }

+0 −10
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLP
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;

import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
@@ -129,15 +128,6 @@ final class InputMonitor {

                // If there's a drag in flight, provide a pseudo-window to catch drag input
                final boolean inDrag = mService.mDragDropController.dragDropActiveLocked();
                if (inDrag) {
                    if (DEBUG_DRAG) {
                        Log.d(TAG_WM, "Inserting drag window");
                    }
                    mService.mDragDropController.showInputSurface(mInputTransaction, mDisplayId);
                } else {
                    mService.mDragDropController.hideInputSurface(mInputTransaction, mDisplayId);
                }

                final boolean inPositioning =
                        mService.mTaskPositioningController.isPositioningLocked();
                if (inPositioning) {