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

Commit 5dc0874b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Return vector of cancellation events"

parents b2ffebef 00fca7c4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2493,8 +2493,8 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(

    nsecs_t currentTime = now();

    std::vector<EventEntry*> cancelationEvents;
    connection->inputState.synthesizeCancelationEvents(currentTime, cancelationEvents, options);
    std::vector<EventEntry*> cancelationEvents =
            connection->inputState.synthesizeCancelationEvents(currentTime, options);

    if (!cancelationEvents.empty()) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
+20 −19
Original line number Diff line number Diff line
@@ -249,17 +249,17 @@ void InputState::MotionMemento::setPointers(const MotionEntry& entry) {
    }
}

void InputState::synthesizeCancelationEvents(nsecs_t currentTime,
                                             std::vector<EventEntry*>& outEvents,
                                             const CancelationOptions& options) {
std::vector<EventEntry*> InputState::synthesizeCancelationEvents(
        nsecs_t currentTime, const CancelationOptions& options) {
    std::vector<EventEntry*> events;
    for (KeyMemento& memento : mKeyMementos) {
        if (shouldCancelKey(memento, options)) {
            outEvents.push_back(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
            events.push_back(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
                                          memento.deviceId, memento.source, memento.displayId,
                                          memento.policyFlags, AKEY_EVENT_ACTION_UP,
                                             memento.flags | AKEY_EVENT_FLAG_CANCELED,
                                             memento.keyCode, memento.scanCode, memento.metaState,
                                             0, memento.downTime));
                                          memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode,
                                          memento.scanCode, memento.metaState, 0 /*repeatCount*/,
                                          memento.downTime));
        }
    }

@@ -267,18 +267,19 @@ void InputState::synthesizeCancelationEvents(nsecs_t currentTime,
        if (shouldCancelMotion(memento, options)) {
            const int32_t action = memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT
                                                    : AMOTION_EVENT_ACTION_CANCEL;
            outEvents.push_back(
                    new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId,
                                    memento.source, memento.displayId, memento.policyFlags, action,
                                    0 /*actionButton*/, memento.flags, AMETA_NONE,
                                    0 /*buttonState*/, MotionClassification::NONE,
            events.push_back(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
                                             memento.deviceId, memento.source, memento.displayId,
                                             memento.policyFlags, action, 0 /*actionButton*/,
                                             memento.flags, AMETA_NONE, 0 /*buttonState*/,
                                             MotionClassification::NONE,
                                             AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
                                             memento.yPrecision, memento.xCursorPosition,
                                    memento.yCursorPosition, memento.downTime, memento.pointerCount,
                                    memento.pointerProperties, memento.pointerCoords, 0 /*xOffset*/,
                                    0 /*yOffset*/));
                                             memento.yCursorPosition, memento.downTime,
                                             memento.pointerCount, memento.pointerProperties,
                                             memento.pointerCoords, 0 /*xOffset*/, 0 /*yOffset*/));
        }
    }
    return events;
}

void InputState::clear() {
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public:
    bool trackMotion(const MotionEntry& entry, int32_t action, int32_t flags);

    // Synthesizes cancelation events for the current state and resets the tracked state.
    void synthesizeCancelationEvents(nsecs_t currentTime, std::vector<EventEntry*>& outEvents,
    std::vector<EventEntry*> synthesizeCancelationEvents(nsecs_t currentTime,
                                                         const CancelationOptions& options);

    // Clears the current state.