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

Commit 5cd091ce authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by android-build-merger
Browse files

Merge "Clear events when ACTION_CANCEL is present" into qt-dev am: cdf3e290 am: 1595a078

am: 97f5b0f0

Change-Id: Id2244bbf9e6bbde85179d783a32a0c21b5c04b19
parents 095421dd 97f5b0f0
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -84,6 +84,10 @@ inline static float lerp(float a, float b, float alpha) {
    return a + alpha * (b - a);
    return a + alpha * (b - a);
}
}


inline static bool isPointerEvent(int32_t source) {
    return (source & AINPUT_SOURCE_CLASS_POINTER) == AINPUT_SOURCE_CLASS_POINTER;
}

// --- InputMessage ---
// --- InputMessage ---


bool InputMessage::isValid(size_t actualSize) const {
bool InputMessage::isValid(size_t actualSize) const {
@@ -637,6 +641,16 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory,
                            mChannel->getName().c_str());
                            mChannel->getName().c_str());
#endif
#endif
                    break;
                    break;
                } else if (isPointerEvent(mMsg.body.motion.source) &&
                        mMsg.body.motion.action == AMOTION_EVENT_ACTION_CANCEL) {
                    // No need to process events that we are going to cancel anyways
                    const size_t count = batch.samples.size();
                    for (size_t i = 0; i < count; i++) {
                        const InputMessage& msg = batch.samples.itemAt(i);
                        sendFinishedSignal(msg.body.motion.seq, false);
                    }
                    batch.samples.removeItemsAt(0, count);
                    mBatches.removeAt(batchIndex);
                } else {
                } else {
                    // We cannot append to the batch in progress, so we need to consume
                    // We cannot append to the batch in progress, so we need to consume
                    // the previous batch right now and defer the new message until later.
                    // the previous batch right now and defer the new message until later.
@@ -759,8 +773,7 @@ status_t InputConsumer::consumeSamples(InputEventFactoryInterface* factory,
}
}


void InputConsumer::updateTouchState(InputMessage& msg) {
void InputConsumer::updateTouchState(InputMessage& msg) {
    if (!mResampleTouch ||
    if (!mResampleTouch || !isPointerEvent(msg.body.motion.source)) {
            !(msg.body.motion.source & AINPUT_SOURCE_CLASS_POINTER)) {
        return;
        return;
    }
    }


@@ -872,7 +885,7 @@ void InputConsumer::rewriteMessage(TouchState& state, InputMessage& msg) {
void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event,
    const InputMessage* next) {
    const InputMessage* next) {
    if (!mResampleTouch
    if (!mResampleTouch
            || !(event->getSource() & AINPUT_SOURCE_CLASS_POINTER)
            || !(isPointerEvent(event->getSource()))
            || event->getAction() != AMOTION_EVENT_ACTION_MOVE) {
            || event->getAction() != AMOTION_EVENT_ACTION_MOVE) {
        return;
        return;
    }
    }