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

Commit cde9548a authored by Yuncheol Heo's avatar Yuncheol Heo
Browse files

Migrate touchable inset calulation from BubbleStackView to TaskView.

Bug: 165794075
Test: Run Bubble demo and check if we can still touch the task inside TaskView.
Change-Id: I15b019cbcda96cdcbdf623495991ca44bc3bc2ed
parent 99e49715
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -29,11 +29,14 @@ import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.util.CloseGuard;
import android.view.SurfaceControl;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewTreeObserver;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;

@@ -44,7 +47,7 @@ import java.util.concurrent.Executor;
 * View that can display a task.
 */
public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        ShellTaskOrganizer.TaskListener {
        ShellTaskOrganizer.TaskListener, ViewTreeObserver.OnComputeInternalInsetsListener {

    /** Callback for listening task state. */
    public interface Listener {
@@ -82,6 +85,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,

    private final Rect mTmpRect = new Rect();
    private final Rect mTmpRootRect = new Rect();
    private final int[] mTmpLocation = new int[2];

    public TaskView(Context context, ShellTaskOrganizer organizer) {
        super(context, null, 0, 0, true /* disableBackgroundLayer */);
@@ -335,4 +339,36 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        mTransaction.reparent(mTaskLeash, null).apply();
        updateTaskVisibility();
    }

    @Override
    public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
        // TODO(b/176854108): Consider to move the logic into gatherTransparentRegions since this
        //   is dependent on the order of listener.
        // If there are multiple TaskViews, we'll set the touchable area as the root-view, then
        // subtract each TaskView from it.
        if (inoutInfo.touchableRegion.isEmpty()) {
            inoutInfo.setTouchableInsets(
                    ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
            View root = getRootView();
            root.getLocationInWindow(mTmpLocation);
            mTmpRootRect.set(mTmpLocation[0], mTmpLocation[1], root.getWidth(), root.getHeight());
            inoutInfo.touchableRegion.set(mTmpRootRect);
        }
        getLocationInWindow(mTmpLocation);
        mTmpRect.set(mTmpLocation[0], mTmpLocation[1],
                mTmpLocation[0] + getWidth(), mTmpLocation[1] + getHeight());
        inoutInfo.touchableRegion.op(mTmpRect, Region.Op.DIFFERENCE);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        getViewTreeObserver().addOnComputeInternalInsetsListener(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
    }
}
+1 −9
Original line number Diff line number Diff line
@@ -1201,16 +1201,8 @@ public class BubbleStackView extends FrameLayout

        mTempRect.setEmpty();
        getTouchableRegion(mTempRect);
        if (mIsExpanded && mExpandedBubble != null
                && mExpandedBubble.getExpandedView() != null
                && mExpandedBubble.getExpandedView().getTaskView() != null) {
            inoutInfo.touchableRegion.set(mTempRect);
            mExpandedBubble.getExpandedView().getTaskView().getBoundsOnScreen(mTempRect);
            inoutInfo.touchableRegion.op(mTempRect, Region.Op.DIFFERENCE);
        } else {
        inoutInfo.touchableRegion.set(mTempRect);
    }
    }

    @Override
    protected void onAttachedToWindow() {