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

Commit b437a5bd authored by Sam Dubey's avatar Sam Dubey Committed by Android (Google) Code Review
Browse files

Merge "Revert "Remove filterNonTouchAsIs function""

parents 52de9695 f886dec0
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -2441,6 +2441,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
    }

    // Update dispatching for hover enter and exit.
    {
        std::vector<TouchedWindow> hoveringWindows =
                getHoveringWindowsLocked(oldState, tempTouchState, entry);
        for (const TouchedWindow& touchedWindow : hoveringWindows) {
@@ -2448,7 +2449,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
                                  touchedWindow.pointerIds, touchedWindow.firstDownTimeInTarget,
                                  targets);
        }

    }
    // Ensure that we have at least one foreground window or at least one window that cannot be a
    // foreground target. If we only have windows that are not receiving foreground touches (e.g. we
    // only have windows getting ACTION_OUTSIDE), then drop the event, because there is no window
@@ -2514,6 +2515,9 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
    }

    outInjectionResult = InputEventInjectionResult::SUCCEEDED;
    // Drop the outside or hover touch windows since we will not care about them
    // in the next iteration.
    tempTouchState.filterNonAsIsTouchWindows();

    // Update final pieces of touch state if the injector had permission.
    if (switchedDevice) {
+14 −0
Original line number Diff line number Diff line
@@ -112,6 +112,20 @@ void TouchState::removeWindowByToken(const sp<IBinder>& token) {
    }
}

void TouchState::filterNonAsIsTouchWindows() {
    for (size_t i = 0; i < windows.size();) {
        TouchedWindow& window = windows[i];
        if (window.targetFlags.any(InputTarget::Flags::DISPATCH_AS_IS |
                                   InputTarget::Flags::DISPATCH_AS_SLIPPERY_ENTER)) {
            window.targetFlags.clear(InputTarget::DISPATCH_MASK);
            window.targetFlags |= InputTarget::Flags::DISPATCH_AS_IS;
            i += 1;
        } else {
            windows.erase(windows.begin() + i);
        }
    }
}

void TouchState::cancelPointersForWindowsExcept(const BitSet32 pointerIds,
                                                const sp<IBinder>& token) {
    if (pointerIds.isEmpty()) return;