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

Commit 889f585a authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Block edge back gesture by mouse pointer

Bug: 403094305
Test: Manual, i.e. verified that back gesture is not triggered by
      mouse pointer drag from edge of screen. Also verified that
      three finger trackpad back gesture remains functional
Flag: com.android.systemui.block_mouse_edge_back_gesture
Change-Id: I0afdbeb1921357a982e4d44c968d07f163c6eaf8
parent 40ae3f5a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2005,6 +2005,16 @@ flag {
    }
}

flag {
    name: "block_mouse_edge_back_gesture"
    namespace: "systemui"
    description: "Blocks the back gesture from being triggered by a mouse pointer."
    bug: "403094305"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "animation_library_shell_migration"
    namespace: "systemui"
+10 −0
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@ import static android.content.pm.ActivityInfo.CONFIG_FONT_SCALE;
import static android.view.InputDevice.SOURCE_MOUSE;
import static android.view.InputDevice.SOURCE_TOUCHPAD;
import static android.view.MotionEvent.TOOL_TYPE_FINGER;
import static android.view.MotionEvent.TOOL_TYPE_MOUSE;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;

import static com.android.systemui.Flags.blockMouseEdgeBackGesture;
import static com.android.systemui.Flags.edgebackGestureHandlerGetRunningTasksBackground;
import static com.android.window.flags.Flags.predictiveBackDelayWmTransition;
import static com.android.systemui.classifier.Classifier.BACK_GESTURE;
@@ -1214,6 +1216,9 @@ public class EdgeBackGestureHandler {
            } else {
                mAllowGesture = isBackAllowedCommon && !mUsingThreeButtonNav && isWithinInsets
                        && isWithinTouchRegion(ev) && !isButtonPressFromTrackpad(ev);
                if (blockMouseEdgeBackGesture()) {
                    mAllowGesture = mAllowGesture && !isButtonPressFromMouse(ev);
                }
            }
            if (mAllowGesture) {
                if (DesktopExperienceFlags.ENABLE_MULTIDISPLAY_TRACKPAD_BACK_GESTURE.isTrue()) {
@@ -1365,6 +1370,11 @@ public class EdgeBackGestureHandler {
                && ev.getToolType(ev.getActionIndex()) == TOOL_TYPE_FINGER;
    }

    private boolean isButtonPressFromMouse(MotionEvent ev) {
        return ev.getSource() == (SOURCE_MOUSE)
                && ev.getToolType(ev.getActionIndex()) == TOOL_TYPE_MOUSE;
    }

    private void dispatchToBackAnimation(MotionEvent event) {
        if (mBackAnimation != null) {
            mBackAnimation.onBackMotion(