InputDispatcher 消息窗口传递过程

 InputDispatcher.InputDispatcherThread::threadLoop--->

dispatchOnce--->

dispatchOnceInnerLocked--->EventEntry::TYPE_MOTION--->

dispatchMotionLocked--->

findTouchedWindowTargetsLocked---->

findTouchedWindowAtLocked

sp InputDispatcher::findTouchedWindowAtLocked(int32_t displayId,
        int32_t x, int32_t y) {
    // Traverse windows from front to back to find touched window.
    size_t numWindows = mWindowHandles.size();
    for (size_t i = 0; i < numWindows; i++) {
        sp windowHandle = mWindowHandles.itemAt(i);
        const InputWindowInfo* windowInfo = windowHandle->getInfo();
        if (windowInfo->displayId == displayId) {
            int32_t flags = windowInfo->layoutParamsFlags;

            if (windowInfo->visible) {
                if (!(flags & InputWindowInfo::FLAG_NOT_TOUCHABLE)) {
                    bool isTouchModal = (flags & (InputWindowInfo::FLAG_NOT_FOCUSABLE
                            | InputWindowInfo::FLAG_NOT_TOUCH_MODAL)) == 0;
                    if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
                        // Found window.
                        return windowHandle;
                    }
                }
            }
        }
    }
    return NULL;
}

如果设置了FLAG_NOT_TOUCHABLE 本窗口不处理TP事件,直接传给下一个窗口。如果FLAG_NOT_FOCUSABLE 和 FLAG_NOT_TOUCH_MODAL 都没有设置,TP事件不会传到下一个窗口,即使这个窗口的大小只有1个像素。

 

你可能感兴趣的:(InputDispatcher 消息窗口传递过程)