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

Commit 71c6f73a authored by jioana's avatar jioana Committed by Ioana Jianu
Browse files

Update MotionEvent's id when a new sample is added.

Until now the MotionEvent's id was set during the "initialize" call, and it was equal to the first sample's eventId. We want to use the latest sample's eventId.

Bug: b/350907221
Test: atest libinput_tests inputflinger_tests
Flag: EXEMPT bugfix

Change-Id: I0d967e7fe644fc2b2c09d044c3ee8ed13276d787
parent 41750190
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -900,9 +900,7 @@ public:
    void splitFrom(const MotionEvent& other, std::bitset<MAX_POINTER_ID + 1> splitPointerIds,
                   int32_t newEventId);

    void addSample(
            nsecs_t eventTime,
            const PointerCoords* pointerCoords);
    void addSample(nsecs_t eventTime, const PointerCoords* pointerCoords, int32_t eventId);

    void offsetLocation(float xOffset, float yOffset);

+4 −4
Original line number Diff line number Diff line
@@ -580,7 +580,7 @@ void MotionEvent::initialize(int32_t id, int32_t deviceId, uint32_t source,
                              &pointerProperties[pointerCount]);
    mSampleEventTimes.clear();
    mSamplePointerCoords.clear();
    addSample(eventTime, pointerCoords);
    addSample(eventTime, pointerCoords, mId);
}

void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) {
@@ -640,9 +640,9 @@ void MotionEvent::splitFrom(const android::MotionEvent& other,
    mSampleEventTimes = other.mSampleEventTimes;
}

void MotionEvent::addSample(
        int64_t eventTime,
        const PointerCoords* pointerCoords) {
void MotionEvent::addSample(int64_t eventTime, const PointerCoords* pointerCoords,
                            int32_t eventId) {
    mId = eventId;
    mSampleEventTimes.push_back(eventTime);
    mSamplePointerCoords.insert(mSamplePointerCoords.end(), &pointerCoords[0],
                                &pointerCoords[getPointerCount()]);
+2 −2
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ void addSample(MotionEvent& event, const InputMessage& msg) {
    }

    event.setMetaState(event.getMetaState() | msg.body.motion.metaState);
    event.addSample(msg.body.motion.eventTime, pointerCoords);
    event.addSample(msg.body.motion.eventTime, pointerCoords, msg.body.motion.eventId);
}

void initializeTouchModeEvent(TouchModeEvent& event, const InputMessage& msg) {
@@ -697,7 +697,7 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
                 currentCoords.getY(), otherCoords.getX(), otherCoords.getY(), alpha);
    }

    event->addSample(sampleTime, touchState.lastResample.pointers);
    event->addSample(sampleTime, touchState.lastResample.pointers, event->getId());
}

status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) {
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ void addSample(MotionEvent& event, const InputMessage& msg) {

    // TODO(b/329770983): figure out if it's safe to combine events with mismatching metaState
    event.setMetaState(event.getMetaState() | msg.body.motion.metaState);
    event.addSample(msg.body.motion.eventTime, pointerCoords.data());
    event.addSample(msg.body.motion.eventTime, pointerCoords.data(), msg.body.motion.eventId);
}

std::unique_ptr<TouchModeEvent> createTouchModeEvent(const InputMessage& msg) {
+1 −1
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ std::unique_ptr<MotionEvent> MotionPredictor::predict(nsecs_t timestamp) {
                                   event.getRawTransform(), event.getDownTime(), predictionTime,
                                   event.getPointerCount(), event.getPointerProperties(), &coords);
        } else {
            prediction->addSample(predictionTime, &coords);
            prediction->addSample(predictionTime, &coords, prediction->getId());
        }

        axisFrom = axisTo;
Loading