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

Commit b49fc5d5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Reset touch state when device resets" into udc-dev

parents e4eb2742 0686f0c4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1461,6 +1461,11 @@ bool InputDispatcher::dispatchDeviceResetLocked(nsecs_t currentTime,
    CancelationOptions options(CancelationOptions::Mode::CANCEL_ALL_EVENTS, "device was reset");
    options.deviceId = entry.deviceId;
    synthesizeCancelationEventsForAllConnectionsLocked(options);

    // Remove all active pointers from this device
    for (auto& [_, touchState] : mTouchStatesByDisplay) {
        touchState.removeAllPointersForDevice(entry.deviceId);
    }
    return true;
}

+12 −0
Original line number Diff line number Diff line
@@ -242,6 +242,18 @@ void TouchState::removeHoveringPointer(int32_t hoveringDeviceId, int32_t hoverin
    clearWindowsWithoutPointers();
}

void TouchState::removeAllPointersForDevice(int32_t removedDeviceId) {
    for (TouchedWindow& window : windows) {
        window.removeAllHoveringPointersForDevice(removedDeviceId);
    }
    if (deviceId == removedDeviceId) {
        for (TouchedWindow& window : windows) {
            window.removeAllTouchingPointers();
        }
    }
    clearWindowsWithoutPointers();
}

std::string TouchState::dump() const {
    std::string out;
    out += StringPrintf("deviceId=%d, source=%s\n", deviceId,
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ struct TouchState {
                                    int32_t deviceId, int32_t hoveringPointerId);
    void removeHoveringPointer(int32_t deviceId, int32_t hoveringPointerId);
    void clearHoveringPointers();

    void removeAllPointersForDevice(int32_t removedDeviceId);
    void removeWindowByToken(const sp<IBinder>& token);
    void filterNonAsIsTouchWindows();

+8 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ void TouchedWindow::removeTouchingPointer(int32_t pointerId) {
    }
}

void TouchedWindow::removeAllTouchingPointers() {
    pointerIds.reset();
}

void TouchedWindow::removeHoveringPointer(int32_t deviceId, int32_t pointerId) {
    const auto it = mHoveringPointerIdsByDevice.find(deviceId);
    if (it == mHoveringPointerIdsByDevice.end()) {
@@ -70,6 +74,10 @@ void TouchedWindow::removeHoveringPointer(int32_t deviceId, int32_t pointerId) {
    }
}

void TouchedWindow::removeAllHoveringPointersForDevice(int32_t deviceId) {
    mHoveringPointerIdsByDevice.erase(deviceId);
}

std::string TouchedWindow::dump() const {
    std::string out;
    std::string hoveringPointers =
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ struct TouchedWindow {
    void addHoveringPointer(int32_t deviceId, int32_t pointerId);
    void removeHoveringPointer(int32_t deviceId, int32_t pointerId);
    void removeTouchingPointer(int32_t pointerId);

    void removeAllTouchingPointers();
    void removeAllHoveringPointersForDevice(int32_t deviceId);
    void clearHoveringPointers();
    std::string dump() const;

Loading