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

Commit 41859c4b authored by Linnan Li's avatar Linnan Li Committed by Cherrypicker Worker
Browse files

Create hover input target by addPointerWindowTargetLocked



The hover event is also pointer event, we should use
addPointerWindowTargetLocked to create input target, this will improve
code maintainability.

Bug: 328151597
Test: atest inputflinger_tests

Signed-off-by: default avatarLinnan Li <lilinnan@xiaomi.corp-partner.google.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:f05a78743cc97f164e867790465f47ed830d46fb)
Merged-In: Ie23d9e4fa2aa79f692624ab286c113d6cdac5b67
Change-Id: Ie23d9e4fa2aa79f692624ab286c113d6cdac5b67
parent d26c9194
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -656,13 +656,13 @@ std::optional<nsecs_t> getDownTime(const EventEntry& eventEntry) {
std::vector<TouchedWindow> getHoveringWindowsLocked(const TouchState* oldState,
                                                    const TouchState& newTouchState,
                                                    const MotionEntry& entry) {
    std::vector<TouchedWindow> out;
    const int32_t maskedAction = MotionEvent::getActionMasked(entry.action);

    if (maskedAction == AMOTION_EVENT_ACTION_SCROLL) {
        // ACTION_SCROLL events should not affect the hovering pointer dispatch
        return {};
    }
    std::vector<TouchedWindow> out;

    // We should consider all hovering pointers here. But for now, just use the first one
    const PointerProperties& pointer = entry.pointerProperties[0];
@@ -2633,19 +2633,14 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked(
    {
        std::vector<TouchedWindow> hoveringWindows =
                getHoveringWindowsLocked(oldState, tempTouchState, entry);
        for (const TouchedWindow& touchedWindow : hoveringWindows) {
            std::optional<InputTarget> target =
                    createInputTargetLocked(touchedWindow.windowHandle, touchedWindow.dispatchMode,
                                            touchedWindow.targetFlags,
                                            touchedWindow.getDownTimeInTarget(entry.deviceId));
            if (!target) {
                continue;
            }
        // Hardcode to single hovering pointer for now.
        std::bitset<MAX_POINTER_ID + 1> pointerIds;
        pointerIds.set(entry.pointerProperties[0].id);
            target->addPointers(pointerIds, touchedWindow.windowHandle->getInfo()->transform);
            targets.push_back(*target);
        for (const TouchedWindow& touchedWindow : hoveringWindows) {
            addPointerWindowTargetLocked(touchedWindow.windowHandle, touchedWindow.dispatchMode,
                                         touchedWindow.targetFlags, pointerIds,
                                         touchedWindow.getDownTimeInTarget(entry.deviceId),
                                         targets);
        }
    }