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

Commit f0007dd3 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Make addGestureMonitors static

The function is already static, but it's marked as if part of
InputDispatcher. Make it clearly static by moving out of
InputDispatcher.h

Bug: none
Test: none
Change-Id: I098e86453b7bb8261e08f7fce671db173e2136b0
parent aefbe1c0
Loading
Loading
Loading
Loading
+24 −32
Original line number Diff line number Diff line
@@ -328,6 +328,18 @@ static std::unique_ptr<DispatchEntry> createDispatchEntry(const InputTarget& inp
    return dispatchEntry;
}

static void addGestureMonitors(const std::vector<Monitor>& monitors,
                               std::vector<TouchedMonitor>& outTouchedMonitors, float xOffset = 0,
                               float yOffset = 0) {
    if (monitors.empty()) {
        return;
    }
    outTouchedMonitors.reserve(monitors.size() + outTouchedMonitors.size());
    for (const Monitor& monitor : monitors) {
        outTouchedMonitors.emplace_back(monitor, xOffset, yOffset);
    }
}

static std::array<uint8_t, 128> getRandomKey() {
    std::array<uint8_t, 128> key;
    if (RAND_bytes(key.data(), key.size()) != 1) {
@@ -741,7 +753,7 @@ sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t display
}

std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
        int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) {
        int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const {
    std::vector<TouchedMonitor> touchedMonitors;

    std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
@@ -755,18 +767,6 @@ std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
    return touchedMonitors;
}

void InputDispatcher::addGestureMonitors(const std::vector<Monitor>& monitors,
                                         std::vector<TouchedMonitor>& outTouchedMonitors,
                                         float xOffset, float yOffset) {
    if (monitors.empty()) {
        return;
    }
    outTouchedMonitors.reserve(monitors.size() + outTouchedMonitors.size());
    for (const Monitor& monitor : monitors) {
        outTouchedMonitors.emplace_back(monitor, xOffset, yOffset);
    }
}

void InputDispatcher::dropInboundEventLocked(const EventEntry& entry, DropReason dropReason) {
    const char* reason;
    switch (dropReason) {
@@ -1267,10 +1267,8 @@ int32_t InputDispatcher::handleTargetsNotReadyLocked(
        }
    } else {
        if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
            if (DEBUG_FOCUS) {
                ALOGD("Waiting for application to become ready for input: %s.  Reason: %s",
            ALOGI("Waiting for application to become ready for input: %s.  Reason: %s",
                  getApplicationWindowLabel(applicationHandle, windowHandle).c_str(), reason);
            }
            nsecs_t timeout;
            if (windowHandle != nullptr) {
                timeout = windowHandle->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
@@ -1506,11 +1504,9 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
    if (newGesture) {
        bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
        if (switchedDevice && mTempTouchState.down && !down && !isHoverAction) {
            if (DEBUG_FOCUS) {
                ALOGD("Dropping event because a pointer for a different device is already down "
            ALOGI("Dropping event because a pointer for a different device is already down "
                  "in display %" PRId32,
                  displayId);
            }
            // TODO: test multiple simultaneous input streams.
            injectionResult = INPUT_EVENT_INJECTION_FAILED;
            switchedDevice = false;
@@ -1524,11 +1520,9 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
        mTempTouchState.displayId = displayId;
        isSplit = false;
    } else if (switchedDevice && maskedAction == AMOTION_EVENT_ACTION_MOVE) {
        if (DEBUG_FOCUS) {
        ALOGI("Dropping move event because a pointer for a different device is already active "
              "in display %" PRId32,
              displayId);
        }
        // TODO: test multiple simultaneous input streams.
        injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
        switchedDevice = false;
@@ -1712,11 +1706,9 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime,
        }
        bool hasGestureMonitor = !mTempTouchState.gestureMonitors.empty();
        if (!haveForegroundWindow && !hasGestureMonitor) {
            if (DEBUG_FOCUS) {
                ALOGD("Dropping event because there is no touched foreground window in display "
            ALOGI("Dropping event because there is no touched foreground window in display "
                  "%" PRId32 " or gesture monitor to receive it.",
                  displayId);
            }
            injectionResult = INPUT_EVENT_INJECTION_FAILED;
            goto Failed;
        }
+1 −4
Original line number Diff line number Diff line
@@ -367,11 +367,8 @@ private:
                                           nsecs_t* nextWakeupTime,
                                           bool* outConflictingPointerActions) REQUIRES(mLock);
    std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked(
            int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows)
            int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const
            REQUIRES(mLock);
    void addGestureMonitors(const std::vector<Monitor>& monitors,
                            std::vector<TouchedMonitor>& outTouchedMonitors, float xOffset = 0,
                            float yOffset = 0);

    void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, int32_t targetFlags,
                               BitSet32 pointerIds, std::vector<InputTarget>& inputTargets)