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

Commit 9be3e787 authored by Ben Lin's avatar Ben Lin
Browse files

PiP: Potentially hide menu immediately after it appears.

PiP currently shows and hides depending on HOVER_ENTER/HOVER_EXIT
events. However, it is possible that user does ENTER/EXIT so quickly
(e.g. fling the cursor across the PIP screen from one corner to the
other), that by the time HOVER_EXIT has happened, the menu activity
hastn' finished showing up yet. If that's the case, #hideMenu would be
called too early, which ends up not hiding anything.

This saves a temporary check such that when the menu appears, if there
is already a signal to hide the menu, then we choose to hide the menu
immediately after.

Bug: 122982825
Test: Fling the cursor from one edge to the other, no longer see the PIP
menu stuck showing.

Change-Id: I946cd2614c0270ffacbaf7d7e6942891095c03ba
parent 83e9ba45
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ public class PipTouchHandler {
    private float mSavedSnapFraction = -1f;
    private boolean mSendingHoverAccessibilityEvents;
    private boolean mMovementWithinDismiss;
    private boolean mHideMenuAfterShown = false;
    private PipAccessibilityInteractionConnection mConnection;

    // Touch state
@@ -677,6 +678,7 @@ public class PipTouchHandler {
                break;
            }
            case MotionEvent.ACTION_HOVER_EXIT: {
                mHideMenuAfterShown = true;
                // If Touch Exploration is enabled, some a11y services (e.g. Talkback) is probably
                // on and changing MotionEvents into HoverEvents.
                // Let's not enable menu show/hide for a11y services.
@@ -767,6 +769,9 @@ public class PipTouchHandler {
                mSavedSnapFraction = mMotionHelper.animateToExpandedState(expandedBounds,
                        mMovementBounds, mExpandedMovementBounds, callback);
            }
            if (mHideMenuAfterShown) {
                mMenuController.hideMenu();
            }
        } else if (menuState == MENU_STATE_NONE && mMenuState == MENU_STATE_FULL) {
            // Try and restore the PiP to the closest edge, using the saved snap fraction
            // if possible
@@ -804,6 +809,7 @@ public class PipTouchHandler {
            }
        }
        mMenuState = menuState;
        mHideMenuAfterShown = false;
        updateMovementBounds();
        // If pip menu has dismissed, we should register the A11y ActionReplacingConnection for pip
        // as well, or it can't handle a11y focus and pip menu can't perform any action.