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

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

Merge "Move shouldSplitTouch into anonymous namespace" into main

parents fbf38057 ce1fd474
Loading
Loading
Loading
Loading
+34 −34
Original line number Diff line number Diff line
@@ -714,6 +714,40 @@ void filterUntrustedTargets(TouchState& touchState, std::vector<InputTarget>& ta
    });
}

/**
 * In general, touch should be always split between windows. Some exceptions:
 * 1. Don't split touch if all of the below is true:
 *     (a) we have an active pointer down *and*
 *     (b) a new pointer is going down that's from the same device *and*
 *     (c) the window that's receiving the current pointer does not support split touch.
 * 2. Don't split mouse events
 */
bool shouldSplitTouch(const TouchState& touchState, const MotionEntry& entry) {
    if (isFromSource(entry.source, AINPUT_SOURCE_MOUSE)) {
        // We should never split mouse events
        return false;
    }
    for (const TouchedWindow& touchedWindow : touchState.windows) {
        if (touchedWindow.windowHandle->getInfo()->isSpy()) {
            // Spy windows should not affect whether or not touch is split.
            continue;
        }
        if (touchedWindow.windowHandle->getInfo()->supportsSplitTouch()) {
            continue;
        }
        if (touchedWindow.windowHandle->getInfo()->inputConfig.test(
                    gui::WindowInfo::InputConfig::IS_WALLPAPER)) {
            // Wallpaper window should not affect whether or not touch is split
            continue;
        }

        if (touchedWindow.hasTouchingPointers(entry.deviceId)) {
            return false;
        }
    }
    return true;
}

} // namespace

// --- InputDispatcher ---
@@ -2218,40 +2252,6 @@ std::vector<Monitor> InputDispatcher::selectResponsiveMonitorsLocked(
    return responsiveMonitors;
}

/**
 * In general, touch should be always split between windows. Some exceptions:
 * 1. Don't split touch is if we have an active pointer down, and a new pointer is going down that's
 *    from the same device, *and* the window that's receiving the current pointer does not support
 *    split touch.
 * 2. Don't split mouse events
 */
bool InputDispatcher::shouldSplitTouch(const TouchState& touchState,
                                       const MotionEntry& entry) const {
    if (isFromSource(entry.source, AINPUT_SOURCE_MOUSE)) {
        // We should never split mouse events
        return false;
    }
    for (const TouchedWindow& touchedWindow : touchState.windows) {
        if (touchedWindow.windowHandle->getInfo()->isSpy()) {
            // Spy windows should not affect whether or not touch is split.
            continue;
        }
        if (touchedWindow.windowHandle->getInfo()->supportsSplitTouch()) {
            continue;
        }
        if (touchedWindow.windowHandle->getInfo()->inputConfig.test(
                    gui::WindowInfo::InputConfig::IS_WALLPAPER)) {
            // Wallpaper window should not affect whether or not touch is split
            continue;
        }

        if (touchedWindow.hasTouchingPointers(entry.deviceId)) {
            return false;
        }
    }
    return true;
}

std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
        nsecs_t currentTime, const MotionEntry& entry, bool* outConflictingPointerActions,
        InputEventInjectionResult& outInjectionResult) {
+0 −1
Original line number Diff line number Diff line
@@ -522,7 +522,6 @@ private:
    // shade is pulled down while we are counting down the timeout).
    void resetNoFocusedWindowTimeoutLocked() REQUIRES(mLock);

    bool shouldSplitTouch(const TouchState& touchState, const MotionEntry& entry) const;
    int32_t getTargetDisplayId(const EventEntry& entry);
    sp<android::gui::WindowInfoHandle> findFocusedWindowTargetLocked(
            nsecs_t currentTime, const EventEntry& entry, nsecs_t* nextWakeupTime,