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

Commit e471edcf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "InputDispatcher: Do not change focus when using transferTouch" into main

parents ea535856 65455c7f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1037,6 +1037,9 @@ std::ostream& operator<<(std::ostream& out, const MotionEvent& event) {
    if (event.getMetaState() != 0) {
        out << ", metaState=" << event.getMetaState();
    }
    if (event.getFlags() != 0) {
        out << ", flags=0x" << std::hex << event.getFlags() << std::dec;
    }
    if (event.getEdgeFlags() != 0) {
        out << ", edgeFlags=" << event.getEdgeFlags();
    }
+8 −3
Original line number Diff line number Diff line
@@ -3422,6 +3422,9 @@ void InputDispatcher::enqueueDispatchEntryLocked(const std::shared_ptr<Connectio
                            InputTarget::Flags::WINDOW_IS_PARTIALLY_OBSCURED)) {
                    resolvedFlags |= AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
                }
                if (dispatchEntry->targetFlags.test(InputTarget::Flags::NO_FOCUS_CHANGE)) {
                    resolvedFlags |= AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE;
                }

                dispatchEntry->resolvedFlags = resolvedFlags;
                if (resolvedAction != motionEntry.action) {
@@ -3496,8 +3499,7 @@ void InputDispatcher::enqueueDispatchEntryLocked(const std::shared_ptr<Connectio
                             << "~ dropping inconsistent event: " << *dispatchEntry;
                return; // skip the inconsistent event
            }

            if ((resolvedMotion->flags & AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE) &&
            if ((dispatchEntry->resolvedFlags & AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE) &&
                (resolvedMotion->policyFlags & POLICY_FLAG_TRUSTED)) {
                // Skip reporting pointer down outside focus to the policy.
                break;
@@ -5612,6 +5614,8 @@ bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<
        if (canReceiveForegroundTouches(*toWindowHandle->getInfo())) {
            newTargetFlags |= InputTarget::Flags::FOREGROUND;
        }
        // Transferring touch focus using this API should not effect the focused window.
        newTargetFlags |= InputTarget::Flags::NO_FOCUS_CHANGE;
        state->addOrUpdateWindow(toWindowHandle, InputTarget::DispatchMode::AS_IS, newTargetFlags,
                                 deviceId, pointers, downTimeInTarget);

@@ -7000,7 +7004,8 @@ void InputDispatcher::transferWallpaperTouch(ftl::Flags<InputTarget::Flags> oldT

    if (newWallpaper != nullptr) {
        nsecs_t downTimeInTarget = now();
        ftl::Flags<InputTarget::Flags> wallpaperFlags = oldTargetFlags & InputTarget::Flags::SPLIT;
        ftl::Flags<InputTarget::Flags> wallpaperFlags = newTargetFlags;
        wallpaperFlags |= oldTargetFlags & InputTarget::Flags::SPLIT;
        wallpaperFlags |= InputTarget::Flags::WINDOW_IS_OBSCURED |
                InputTarget::Flags::WINDOW_IS_PARTIALLY_OBSCURED;
        state.addOrUpdateWindow(newWallpaper, InputTarget::DispatchMode::AS_IS, wallpaperFlags,
+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ enum class InputTargetFlags : uint32_t {
     * the same UID from watching all touches. */
    ZERO_COORDS = 1 << 3,

    /* This flag indicates that the event will not cause a focus change if it is directed to an
     * unfocused window, even if it an ACTION_DOWN. This is typically used to allow gestures to be
     * directed to an unfocused window without bringing it into focus. The motion event should be
     * delivered with flag AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE. */
    NO_FOCUS_CHANGE = 1 << 4,

    /* This flag indicates that the target of a MotionEvent is partly or wholly
     * obscured by another visible window above it.  The motion event should be
     * delivered with flag AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED. */
+4 −1
Original line number Diff line number Diff line
@@ -140,7 +140,9 @@ public:
     */
    virtual void setMaximumObscuringOpacityForTouch(float opacity) = 0;

    /* Transfers touch focus from one window to another window.
    /**
     * Transfers touch focus from one window to another window. Transferring touch focus will not
     * have any effect on the focused window.
     *
     * Returns true on success.  False if the window did not actually have touch focus.
     */
@@ -149,6 +151,7 @@ public:

    /**
     * Transfer touch focus to the provided channel, no matter where the current touch is.
     * Transferring touch focus will not have any effect on the focused window.
     *
     * Return true on success, false if there was no on-going touch.
     */
+66 −48

File changed.

Preview size limit exceeded, changes collapsed.