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

Commit 5a619092 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Give Divider back its touch-region" into rvc-dev

parents 64b88db3 12837281
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -342,5 +342,5 @@ interface IWindowSession {
     * Update the flags on an input channel associated with a particular surface.
     */
    void updateInputChannel(in IBinder channelToken, int displayId, in SurfaceControl surface,
            int flags);
            int flags, in Region region);
}
+8 −0
Original line number Diff line number Diff line
@@ -233,6 +233,14 @@ public class SurfaceControlViewHost {
        return mViewRoot.mWindow;
    }

    /**
     * @return the WindowlessWindowManager instance that this host is attached to.
     * @hide
     */
    public @NonNull WindowlessWindowManager getWindowlessWM() {
        return mWm;
    }

    /**
     * @hide
     */
+30 −2
Original line number Diff line number Diff line
@@ -16,16 +16,19 @@

package android.view;

import android.annotation.Nullable;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.util.MergedConfiguration;

import java.util.HashMap;
import java.util.Objects;

/**
* A simplistic implementation of IWindowSession. Rather than managing Surfaces
@@ -42,6 +45,7 @@ public class WindowlessWindowManager implements IWindowSession {
        WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
        int mDisplayId;
        IBinder mInputChannelToken;
        Region mInputRegion;
        State(SurfaceControl sc, WindowManager.LayoutParams p, int displayId,
                IBinder inputChannelToken) {
            mSurfaceControl = sc;
@@ -95,6 +99,30 @@ public class WindowlessWindowManager implements IWindowSession {
        mResizeCompletionForWindow.put(window, callback);
    }

    protected void setTouchRegion(IBinder window, @Nullable Region region) {
        State state;
        synchronized (this) {
            // Do everything while locked so that we synchronize with relayout. This should be a
            // very infrequent operation.
            state = mStateForWindow.get(window);
            if (state == null) {
                return;
            }
            if (Objects.equals(region, state.mInputRegion)) {
                return;
            }
            state.mInputRegion = region != null ? new Region(region) : null;
            if (state.mInputChannelToken != null) {
                try {
                    mRealWm.updateInputChannel(state.mInputChannelToken, state.mDisplayId,
                            state.mSurfaceControl, state.mParams.flags, state.mInputRegion);
                } catch (RemoteException e) {
                    Log.e(TAG, "Failed to update surface input channel: ", e);
                }
            }
        }
    }

    /**
     * IWindowSession implementation.
     */
@@ -234,7 +262,7 @@ public class WindowlessWindowManager implements IWindowSession {
                && state.mInputChannelToken != null) {
            try {
                mRealWm.updateInputChannel(state.mInputChannelToken, state.mDisplayId, sc,
                        attrs.flags);
                        attrs.flags, state.mInputRegion);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to update surface input channel: ", e);
            }
@@ -409,7 +437,7 @@ public class WindowlessWindowManager implements IWindowSession {

    @Override
    public void updateInputChannel(IBinder channelToken, int displayId, SurfaceControl surface,
            int flags) {
            int flags, Region region) {
    }

    @Override
+16 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
import android.hardware.display.DisplayManager;
import android.os.Bundle;
@@ -338,12 +339,12 @@ public class DividerView extends FrameLayout implements OnTouchListener,

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (mFirstLayout) {
            // Wait for first layout so that the ViewRootImpl surface has been created.
            initializeSurfaceState();
            mFirstLayout = false;
        }
        super.onLayout(changed, left, top, right, bottom);
        int minimizeLeft = 0;
        int minimizeTop = 0;
        if (mDockSide == WindowManager.DOCKED_TOP) {
@@ -783,6 +784,20 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        setResizeDimLayer(t, false /* secondary */, 0.f /* alpha */);
        t.apply();
        mTiles.releaseTransaction(t);

        // Get the actually-visible bar dimensions (relative to full window). This is a thin
        // bar going through the center.
        final Rect dividerBar = isHorizontalDivision()
                ? new Rect(0, mDividerInsets, mSplitLayout.mDisplayLayout.width(),
                mDividerInsets + mDividerSize)
                : new Rect(mDividerInsets, 0, mDividerInsets + mDividerSize,
                mSplitLayout.mDisplayLayout.height());
        final Region touchRegion = new Region(dividerBar);
        // Add in the "draggable" portion. While not visible, this is an expanded area that the
        // user can interact with.
        touchRegion.union(new Rect(mHandle.getLeft(), mHandle.getTop(),
                mHandle.getRight(), mHandle.getBottom()));
        mWindowManager.setTouchRegion(touchRegion);
    }

    public void setMinimizedDockStack(boolean minimized, boolean isHomeStackResizable) {
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMA
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;

import android.graphics.PixelFormat;
import android.graphics.Region;
import android.os.Binder;
import android.view.View;
import android.view.WindowManager;
@@ -103,4 +104,12 @@ public class DividerWindowManager {
            mSystemWindows.updateViewLayout(mView, mLp);
        }
    }

    /** Sets the touch region to `touchRegion`. Use null to unset.*/
    public void setTouchRegion(Region touchRegion) {
        if (mView == null) {
            return;
        }
        mSystemWindows.setTouchableRegion(mView, touchRegion);
    }
}
Loading