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

Commit c02a1b90 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Allow back navigation from window edge on certain motion events.

If edge resize is permitted (e.g. using stylus, mouse) then exclude
touch regions so that window can be resized from edge. If not, (e.g.
using finger), then don't exclude touch region so users can go back from
the edge of the window.

Test: manual, position window near right edge, going back using finger
works, and using stylus resizes the window as expected.
Fixes: 362598831
Flag: com.android.window.flags.enable_windowing_edge_drag_resize

Change-Id: I2ca41383f79ce37441c630a119e2e233391514e4
parent 57724986
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -168,7 +168,10 @@ public final class DragResizeWindowGeometry {
        return (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN;
    }

    static boolean isEdgeResizePermitted(@NonNull MotionEvent e) {
    /**
     * Whether resizing a window from the edge is permitted based on the motion event.
     */
    public static boolean isEdgeResizePermitted(@NonNull MotionEvent e) {
        if (ENABLE_WINDOWING_EDGE_DRAG_RESIZE.isTrue()) {
            return e.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
                    || e.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE
+7 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadScroll;
import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TOUCHPAD_GESTURES_DISABLED;
import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.isEdgeResizePermitted;

import static java.util.stream.Collectors.joining;

@@ -965,11 +966,14 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
        return mDesktopModeExcludeRegion.contains(x, y);
    }

    private boolean isWithinTouchRegion(int x, int y) {
    private boolean isWithinTouchRegion(MotionEvent ev) {
        // If the point is inside the PiP or Nav bar overlay excluded bounds, then ignore the back
        // gesture
        int x = (int) ev.getX();
        int y = (int) ev.getY();
        final boolean isInsidePip = mIsInPip && mPipExcludedBounds.contains(x, y);
        final boolean isInDesktopExcludeRegion = desktopExcludeRegionContains(x, y);
        final boolean isInDesktopExcludeRegion = desktopExcludeRegionContains(x, y)
                && isEdgeResizePermitted(ev);
        if (isInsidePip || isInDesktopExcludeRegion
                || mNavBarOverlayExcludedBounds.contains(x, y)) {
            return false;
@@ -1098,8 +1102,7 @@ public class EdgeBackGestureHandler implements PluginListener<NavigationEdgeBack
                        && isValidTrackpadBackGesture(true /* isTrackpadEvent */);
            } else {
                mAllowGesture = isBackAllowedCommon && !mUsingThreeButtonNav && isWithinInsets
                        && isWithinTouchRegion((int) ev.getX(), (int) ev.getY())
                        && !isButtonPressFromTrackpad(ev);
                        && isWithinTouchRegion(ev) && !isButtonPressFromTrackpad(ev);
            }
            if (mAllowGesture) {
                mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge);