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

Commit d53ed1f6 authored by Robert Carr's avatar Robert Carr Committed by Automerger Merge Worker
Browse files

DO NOT MERGE: InputDispatcher: Consider ownerPid in FLAG_OBSCURED calculations am: 9cada03f

Change-Id: I22cb46d05a0e3d816a9d39107b8c1ae8dec0d149
parents 91fb0a98 9cada03f
Loading
Loading
Loading
Loading
+40 −9
Original line number Original line Diff line number Diff line
@@ -1986,18 +1986,49 @@ bool InputDispatcher::checkInjectionPermission(const sp<InputWindowHandle>& wind
    return true;
    return true;
}
}


/**
 * Indicate whether one window handle should be considered as obscuring
 * another window handle. We only check a few preconditions. Actually
 * checking the bounds is left to the caller.
 */
static bool canBeObscuredBy(const sp<InputWindowHandle>& windowHandle,
                            const sp<InputWindowHandle>& otherHandle) {
    // Compare by token so cloned layers aren't counted
    if (haveSameToken(windowHandle, otherHandle)) {
        return false;
    }
    auto info = windowHandle->getInfo();
    auto otherInfo = otherHandle->getInfo();
    if (!otherInfo->visible) {
        return false;
    } else if (info->ownerPid == otherInfo->ownerPid && otherHandle->getToken() == nullptr) {
      // In general, if ownerPid is the same we don't want to generate occlusion
      // events. This line is now necessary since we are including all Surfaces
      // in occlusion calculation, so if we didn't check PID like this SurfaceView
      // would occlude their parents. On the other hand before we started including
      // all surfaces in occlusion calculation and had this line, we would count
      // windows with an input channel from the same PID as occluding, and so we
      // preserve this behavior with the getToken() == null check.
        return false;
    } else if (otherInfo->isTrustedOverlay()) {
        return false;
    } else if (otherInfo->displayId != info->displayId) {
        return false;
    }
    return true;
}

bool InputDispatcher::isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle,
bool InputDispatcher::isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle,
                                                    int32_t x, int32_t y) const {
                                                    int32_t x, int32_t y) const {
    int32_t displayId = windowHandle->getInfo()->displayId;
    int32_t displayId = windowHandle->getInfo()->displayId;
    const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
    const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
    for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
    for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
        if (otherHandle == windowHandle) {
        if (windowHandle == otherHandle) {
            break;
            break; // All future windows are below us. Exit early.
        }
        }

        const InputWindowInfo* otherInfo = otherHandle->getInfo();
        const InputWindowInfo* otherInfo = otherHandle->getInfo();
        if (otherInfo->displayId == displayId && otherInfo->visible &&
          if (canBeObscuredBy(windowHandle, otherHandle) &&
            !otherInfo->isTrustedOverlay() && otherInfo->frameContainsPoint(x, y)) {
            otherInfo->frameContainsPoint(x, y)) {
            return true;
            return true;
        }
        }
    }
    }
@@ -2009,13 +2040,13 @@ bool InputDispatcher::isWindowObscuredLocked(const sp<InputWindowHandle>& window
    const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
    const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
    const InputWindowInfo* windowInfo = windowHandle->getInfo();
    const InputWindowInfo* windowInfo = windowHandle->getInfo();
    for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
    for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
        if (otherHandle == windowHandle) {
        if (windowHandle == otherHandle) {
            break;
            break; // All future windows are below us. Exit early.
        }
        }


        const InputWindowInfo* otherInfo = otherHandle->getInfo();
        const InputWindowInfo* otherInfo = otherHandle->getInfo();
        if (otherInfo->displayId == displayId && otherInfo->visible &&
        if (canBeObscuredBy(windowHandle, otherHandle) &&
            !otherInfo->isTrustedOverlay() && otherInfo->overlaps(windowInfo)) {
            otherInfo->overlaps(windowInfo)) {
            return true;
            return true;
        }
        }
    }
    }