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

Commit a5fd5063 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "Create hover input target by addPointerWindowTargetLocked" into main

parents 9ba1cc57 41859c4b
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -676,13 +676,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];
@@ -2651,19 +2651,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);
        }
    }