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

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

Merge "Only send events to windows with pointers"

parents 6f5ed5b8 e0431e40
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -2303,8 +2303,13 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
                pointerIds.markBit(entry.pointerProperties[pointerIndex].id);
            }

            const bool isDownOrPointerDown = maskedAction == AMOTION_EVENT_ACTION_DOWN ||
                    maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN;

            tempTouchState.addOrUpdateWindow(windowHandle, targetFlags, pointerIds,
                                             entry.eventTime);
                                             isDownOrPointerDown
                                                     ? std::make_optional(entry.eventTime)
                                                     : std::nullopt);

            // If this is the pointer going down and the touched window has a wallpaper
            // then also add the touched wallpaper windows so they are locked in for the duration
@@ -2312,8 +2317,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
            // We do not collect wallpapers during HOVER_MOVE or SCROLL because the wallpaper
            // engine only supports touch events.  We would need to add a mechanism similar
            // to View.onGenericMotionEvent to enable wallpapers to handle these events.
            if (maskedAction == AMOTION_EVENT_ACTION_DOWN ||
                maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN) {
            if (isDownOrPointerDown) {
                if (targetFlags.test(InputTarget::Flags::FOREGROUND) &&
                    windowHandle->getInfo()->inputConfig.test(
                            gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)) {
@@ -2517,6 +2521,12 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
    // Success!  Output targets from the touch state.
    tempTouchState.clearWindowsWithoutPointers();
    for (const TouchedWindow& touchedWindow : tempTouchState.windows) {
        if (touchedWindow.pointerIds.isEmpty() &&
            !touchedWindow.hasHoveringPointers(entry.deviceId)) {
            // Windows with hovering pointers are getting persisted inside TouchState.
            // Do not send this event to those windows.
            continue;
        }
        addWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.targetFlags,
                              touchedWindow.pointerIds, touchedWindow.firstDownTimeInTarget,
                              targets);
+3 −3
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ void TouchState::clearWindowsWithoutPointers() {

void TouchState::addOrUpdateWindow(const sp<WindowInfoHandle>& windowHandle,
                                   ftl::Flags<InputTarget::Flags> targetFlags, BitSet32 pointerIds,
                                   std::optional<nsecs_t> eventTime) {
                                   std::optional<nsecs_t> firstDownTimeInTarget) {
    for (TouchedWindow& touchedWindow : windows) {
        // We do not compare windows by token here because two windows that share the same token
        // may have a different transform
@@ -77,7 +77,7 @@ void TouchState::addOrUpdateWindow(const sp<WindowInfoHandle>& windowHandle,
            // the window.
            touchedWindow.pointerIds.value |= pointerIds.value;
            if (!touchedWindow.firstDownTimeInTarget.has_value()) {
                touchedWindow.firstDownTimeInTarget = eventTime;
                touchedWindow.firstDownTimeInTarget = firstDownTimeInTarget;
            }
            return;
        }
@@ -86,7 +86,7 @@ void TouchState::addOrUpdateWindow(const sp<WindowInfoHandle>& windowHandle,
    touchedWindow.windowHandle = windowHandle;
    touchedWindow.targetFlags = targetFlags;
    touchedWindow.pointerIds = pointerIds;
    touchedWindow.firstDownTimeInTarget = eventTime;
    touchedWindow.firstDownTimeInTarget = firstDownTimeInTarget;
    windows.push_back(touchedWindow);
}

+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ struct TouchState {
                                        const sp<android::gui::WindowInfoHandle>& windowHandle);
    void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
                           ftl::Flags<InputTarget::Flags> targetFlags, BitSet32 pointerIds,
                           std::optional<nsecs_t> eventTime = std::nullopt);
                           std::optional<nsecs_t> firstDownTimeInTarget = std::nullopt);
    void addHoveringPointerToWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
                                    int32_t deviceId, int32_t hoveringPointerId);
    void removeHoveringPointer(int32_t deviceId, int32_t hoveringPointerId);
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@ bool TouchedWindow::hasHoveringPointers() const {
    return !mHoveringPointerIdsByDevice.empty();
}

bool TouchedWindow::hasHoveringPointers(int32_t deviceId) const {
    return mHoveringPointerIdsByDevice.find(deviceId) != mHoveringPointerIdsByDevice.end();
}

void TouchedWindow::clearHoveringPointers() {
    mHoveringPointerIdsByDevice.clear();
}
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ struct TouchedWindow {
    std::optional<nsecs_t> firstDownTimeInTarget;

    bool hasHoveringPointers() const;
    bool hasHoveringPointers(int32_t deviceId) const;

    bool hasHoveringPointer(int32_t deviceId, int32_t pointerId) const;
    void addHoveringPointer(int32_t deviceId, int32_t pointerId);
Loading