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

Commit 9306c387 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use consistent coordinate extraction code in dispatcher

Consolidate the code for extraction of the coordinates from MotionEntry.
This allows us to more easily change the behaviour in the future.

In this CL, there will be a behaviour change that we will now use mouse
cursor position for some of the location resolution instead of pointer.
This should be OK to do.

Bug: 250029068
Test: atest inputflinger_tests
Change-Id: I137c26f881ad993f7a7463c2c05674e48cf864f4
parent 275b30fe
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -936,13 +936,10 @@ bool InputDispatcher::shouldPruneInboundQueueLocked(const MotionEntry& motionEnt
    // If the application takes too long to catch up then we drop all events preceding
    // the touch into the other window.
    if (isPointerDownEvent && mAwaitedFocusedApplication != nullptr) {
        int32_t displayId = motionEntry.displayId;
        int32_t x = static_cast<int32_t>(
                motionEntry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
        int32_t y = static_cast<int32_t>(
                motionEntry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));

        const int32_t displayId = motionEntry.displayId;
        const auto [x, y] = resolveTouchedPosition(motionEntry);
        const bool isStylus = isPointerFromStylus(motionEntry, 0 /*pointerIndex*/);

        sp<WindowInfoHandle> touchedWindowHandle =
                findTouchedWindowAtLocked(displayId, x, y, nullptr, isStylus);
        if (touchedWindowHandle != nullptr &&
@@ -2202,9 +2199,7 @@ InputEventInjectionResult InputDispatcher::findTouchedWindowTargetsLocked(
        // Check whether touches should slip outside of the current foreground window.
        if (maskedAction == AMOTION_EVENT_ACTION_MOVE && entry.pointerCount == 1 &&
            tempTouchState.isSlippery()) {
            const int32_t x = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
            const int32_t y = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));

            const auto [x, y] = resolveTouchedPosition(entry);
            const bool isStylus = isPointerFromStylus(entry, 0 /*pointerIndex*/);
            sp<WindowInfoHandle> oldTouchedWindowHandle =
                    tempTouchState.getFirstForegroundWindowHandle();